Skip to content

feat(Table): update isPlain to apply no-plain when false#12287

Open
kmcfaul wants to merge 4 commits intopatternfly:mainfrom
kmcfaul:glass-updates-table
Open

feat(Table): update isPlain to apply no-plain when false#12287
kmcfaul wants to merge 4 commits intopatternfly:mainfrom
kmcfaul:glass-updates-table

Conversation

@kmcfaul
Copy link
Contributor

@kmcfaul kmcfaul commented Mar 23, 2026

What: Closes #12272

  • Adds isNoPlainOnGlass flag to apply pf-m-no-plain.
  • Adds unit tests for isNoPlainOnGlass.

Summary by CodeRabbit

  • Improvements

    • Added an option to control plain-style rendering when tables sit on glass/transparent backgrounds, improving visual consistency while preserving existing plain-style precedence.
  • Tests

    • Added tests validating plain-style and glass-background behavior across all relevant states.

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Walkthrough

Added an optional isNoPlainOnGlass?: boolean prop (default false) to the Table component; when true the table className includes styles.modifiers.noPlain. If both isPlain and isNoPlainOnGlass are true, a console warning is emitted and isPlain remains applied. Tests added to verify modifier-class presence across prop combinations.

Changes

Cohort / File(s) Summary
Table component
packages/react-table/src/components/Table/Table.tsx
Added optional prop isNoPlainOnGlass?: boolean (default false); className computation now conditionally includes styles.modifiers.noPlain when isNoPlainOnGlass is true; emits a console warning when both isPlain and isNoPlainOnGlass are true.
Table tests
packages/react-table/src/components/Table/__tests__/Table.test.tsx
Added tests (5) asserting presence/absence of styles.modifiers.plain and styles.modifiers.noPlain across isPlain and isNoPlainOnGlass combinations (undefined/false/true).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • nicolethoen
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and does not clearly convey the main change. The phrase 'update isPlain to apply no-plain when false' is confusing and misleading since the actual implementation adds a new isNoPlainOnGlass prop. Consider revising the title to accurately reflect the main change, such as 'feat(Table): add isNoPlainOnGlass prop to apply no-plain modifier' for better clarity.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request implements the core requirement from #12272 by adding isNoPlainOnGlass prop to apply pf-m-no-plain modifier, with comprehensive unit tests validating the behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing isNoPlainOnGlass functionality and its tests. The addition of a warning when both isPlain and isNoPlainOnGlass are true is a reasonable safeguard within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kmcfaul kmcfaul changed the title Glass updates table @kmcfaul feat(Table): update isPlain to apply no-plain when false Mar 23, 2026
@kmcfaul kmcfaul changed the title @kmcfaul feat(Table): update isPlain to apply no-plain when false feat(Table): update isPlain to apply no-plain when false Mar 23, 2026
@patternfly-build
Copy link
Collaborator

patternfly-build commented Mar 23, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/react-table/src/components/Table/Table.tsx`:
- Around line 53-54: The Table component currently introduces a new public prop
isNoPlainOnGlass instead of making explicit isPlain={false} produce the
pf-m-no-plain modifier; remove or ignore the public isNoPlainOnGlass usage and
change the class-computation logic in the Table component (where you previously
referenced isNoPlainOnGlass and isPlain) to add the "pf-m-no-plain" class when
the theme is glass AND isPlain === false (strict check for explicit false),
leaving isPlain as an optional prop (do not set a default that masks undefined)
so you can detect an explicit false; update all places that previously used
isNoPlainOnGlass (and relevant className concatenations) to use this new
explicit-check logic and remove the redundant prop from the component API.
- Around line 231-233: The code currently adds both plain and noPlain modifiers
which can conflict; update the class logic so the noPlain modifier
(styles.modifiers.noPlain) is only applied when isNoPlainOnGlass is true AND
isPlain is false (e.g., change the predicate to isNoPlainOnGlass && !isPlain)
while leaving isPlain && styles.modifiers.plain and hasNoInset &&
stylesTreeView.modifiers.noInset unchanged; locate this in the Table component
where isPlain, isNoPlainOnGlass, styles.modifiers.plain and
styles.modifiers.noPlain are used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75876afa-0a2b-415e-a198-ab561dd936b1

📥 Commits

Reviewing files that changed from the base of the PR and between c7dd546 and 86853d0.

📒 Files selected for processing (2)
  • packages/react-table/src/components/Table/Table.tsx
  • packages/react-table/src/components/Table/__tests__/Table.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-table/src/components/Table/tests/Table.test.tsx

/** @beta Flag indicating if the table should have plain styling with a transparent background */
isPlain?: boolean;
/** @beta Flag indicating if the table should not have plain styling when in the glass theme */
isNoPlainOnGlass?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe isPlainOnGlass is more accurate since setting it to true removes the modifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it to true is what sets the no-plain modifier.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/react-table/src/components/Table/Table.tsx (1)

95-103: ⚠️ Potential issue | 🟠 Major

isPlain precedence is not actually enforced, and explicit isPlain={false} is still not represented in class logic.

At Line 130, the warning says isNoPlainOnGlass is ignored when isPlain is true, but Line 239 still adds styles.modifiers.noPlain, so both modifiers can be emitted together. Also, current logic still does not map explicit isPlain={false} to pf-m-no-plain as described in the linked objective.

Proposed fix
-const TableBase: React.FunctionComponent<TableProps> = ({
+const TableBase: React.FunctionComponent<TableProps> = (tableProps: TableProps) => {
+  const {
   children,
   className,
   variant,
   borders = true,
   isStickyHeader = false,
   isPlain = false,
   isNoPlainOnGlass = false,
   gridBreakPoint = TableGridBreakpoint.gridMd,
   'aria-label': ariaLabel,
   role = 'grid',
   innerRef,
   ouiaId,
   ouiaSafe = true,
   isTreeTable = false,
   isNested = false,
   isStriped = false,
   isExpandable = false,
   hasAnimations: hasAnimationsProp,
   hasNoInset = false,
   // eslint-disable-next-line `@typescript-eslint/no-unused-vars`
   nestedHeaderColumnSpans,
   selectableRowCaptionText,
   ...props
-}: TableProps) => {
+  } = tableProps;
+
+  const isPlainExplicitlyFalse =
+    Object.prototype.hasOwnProperty.call(tableProps, 'isPlain') && tableProps.isPlain === false;
+  const shouldApplyNoPlain = isNoPlainOnGlass || isPlainExplicitlyFalse;

-  if (isPlain && isNoPlainOnGlass) {
+  if (isPlain && shouldApplyNoPlain) {
     // eslint-disable-next-line no-console
     console.warn(
       "Table: When both isPlain and isNoPlainOnGlass are true, isPlain will take precedence and isNoPlainOnGlass will have no effect. It's recommended to pass only one prop according to the current theme."
     );
   }

@@
-          isNoPlainOnGlass && styles.modifiers.noPlain,
+          !isPlain && shouldApplyNoPlain && styles.modifiers.noPlain,

Based on learnings: In PatternFly React, isPlain should remain defaulted to false, and explicit-false handling should not require changing that default.

Also applies to: 127-132, 238-239

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-table/src/components/Table/Table.tsx` around lines 95 - 103,
TableBase's class logic must treat isPlain precedence correctly and detect
explicit isPlain={false}; stop defaulting isPlain in the parameter list and
instead read it from the props object so you can detect whether it was provided
(use Object.prototype.hasOwnProperty.call(props, 'isPlain')). In TableBase, if
isPlain === true then ignore isNoPlainOnGlass and do NOT add
styles.modifiers.noPlain; otherwise add styles.modifiers.noPlain when either (a)
isPlain was explicitly set to false or (b) isNoPlainOnGlass is true and isPlain
is not true. Update the class-name construction to use this detection and keep
the prop default behavior (treat undefined as false for rendering) while
enforcing the precedence rules for isPlain and isNoPlainOnGlass.
🧹 Nitpick comments (1)
packages/react-table/src/components/Table/Table.tsx (1)

127-132: Move warning logic to useEffect to avoid side effects in render.

The console.warn currently runs on every render when both isPlain and isNoPlainOnGlass are true, violating React's requirement that render functions remain pure. Side effects like logging should run in useEffect instead, which executes after render. Since useEffect is already imported, wrapping this warning with dependencies [isPlain, isNoPlainOnGlass] will ensure it only triggers when those props change, not on every render.

Suggested refactor
-  if (isPlain && isNoPlainOnGlass) {
-    // eslint-disable-next-line no-console
-    console.warn(
-      "Table: When both isPlain and isNoPlainOnGlass are true, isPlain will take precedence and isNoPlainOnGlass will have no effect. It's recommended to pass only one prop according to the current theme."
-    );
-  }
+  useEffect(() => {
+    if (isPlain && isNoPlainOnGlass) {
+      // eslint-disable-next-line no-console
+      console.warn(
+        "Table: When both isPlain and isNoPlainOnGlass are true, isPlain will take precedence and isNoPlainOnGlass will have no effect. It's recommended to pass only one prop according to the current theme."
+      );
+    }
+  }, [isPlain, isNoPlainOnGlass]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react-table/src/components/Table/Table.tsx` around lines 127 - 132,
The render currently logs a warning when both isPlain and isNoPlainOnGlass are
true, causing a side effect inside the Table component render; move that
console.warn into a useEffect inside the Table component (use the existing
useEffect import) and run it with dependencies [isPlain, isNoPlainOnGlass] so
the warning only fires when those props change, preserving render purity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/react-table/src/components/Table/Table.tsx`:
- Around line 95-103: TableBase's class logic must treat isPlain precedence
correctly and detect explicit isPlain={false}; stop defaulting isPlain in the
parameter list and instead read it from the props object so you can detect
whether it was provided (use Object.prototype.hasOwnProperty.call(props,
'isPlain')). In TableBase, if isPlain === true then ignore isNoPlainOnGlass and
do NOT add styles.modifiers.noPlain; otherwise add styles.modifiers.noPlain when
either (a) isPlain was explicitly set to false or (b) isNoPlainOnGlass is true
and isPlain is not true. Update the class-name construction to use this
detection and keep the prop default behavior (treat undefined as false for
rendering) while enforcing the precedence rules for isPlain and
isNoPlainOnGlass.

---

Nitpick comments:
In `@packages/react-table/src/components/Table/Table.tsx`:
- Around line 127-132: The render currently logs a warning when both isPlain and
isNoPlainOnGlass are true, causing a side effect inside the Table component
render; move that console.warn into a useEffect inside the Table component (use
the existing useEffect import) and run it with dependencies [isPlain,
isNoPlainOnGlass] so the warning only fires when those props change, preserving
render purity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bfc79189-f0c1-45d1-bc66-4baff6fd5ff6

📥 Commits

Reviewing files that changed from the base of the PR and between 86853d0 and 213a741.

📒 Files selected for processing (1)
  • packages/react-table/src/components/Table/Table.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table - glass style follow up

3 participants