Skip to content

feat(RHINENG-24161): align PolicyTypeTable cells vertically#2849

Closed
opacut wants to merge 1 commit into
RedHatInsights:masterfrom
opacut:RHINENG-24161
Closed

feat(RHINENG-24161): align PolicyTypeTable cells vertically#2849
opacut wants to merge 1 commit into
RedHatInsights:masterfrom
opacut:RHINENG-24161

Conversation

@opacut

@opacut opacut commented May 29, 2026

Copy link
Copy Markdown
Contributor

Aligns table cells vertically to the middle in the PolicyTypeTable component by wrapping the table in a div with an inline style block.

  • wrapped TableToolsTable in a <div className="policy-type-table">
  • added inline <style> block to vertically align radio button cells
  • added tableBodyProps={{ style: { verticalAlign: 'middle' } }} to vertically align text cells

How to test

  1. Set up local environment according to readme
  2. Navigate to Create new policy modal
  3. Select a OS version
  4. Table cells (text and radio buttons) should be vertically aligned to the middle

🤖 Generated with Claude Code

Summary by Sourcery

Enhancements:

  • Wrap PolicyTypeTable in a container that applies middle vertical alignment to table body cells and check/radio column.

@opacut opacut requested a review from a team as a code owner May 29, 2026 13:11
@sourcery-ai

sourcery-ai Bot commented May 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Wraps PolicyTypeTable in a container that applies middle vertical alignment to table cells via inline styles and new TableToolsTable props, ensuring text and radio buttons are vertically centered.

File-Level Changes

Change Details Files
Add wrapper container and inline styles to vertically center table cell content in PolicyTypeTable.
  • Wrap the PolicyTypeTable JSX in a div with a policy-type-table class to scope styling
  • Inject a style tag that sets vertical-align: middle on .pf-v6-c-table__check cells to vertically center selection controls
  • Pass tableBodyProps with an inline style of verticalAlign: 'middle' to TableToolsTable so table body cells are vertically centered
src/PresentationalComponents/PolicyTypesTable/PolicyTypeTable.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • Avoid rendering a <style> tag inside the component on every render; instead, move the .pf-v6-c-table__check { vertical-align: middle; } rule into a shared stylesheet or CSS module and reuse the existing policy-type-table class or a new className for scoping.
  • The wrapper <div className="policy-type-table"> is currently only used to host the inline <style> tag; once the styling is moved to a stylesheet, consider removing the wrapper to avoid unnecessary DOM nesting unless you need it for layout.
  • You are now setting vertical alignment both via the .pf-v6-c-table__check rule and tableBodyProps={{ style: { verticalAlign: 'middle' } }}; consider consolidating to a single, clearly scoped approach to avoid confusion and potential style conflicts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Avoid rendering a `<style>` tag inside the component on every render; instead, move the `.pf-v6-c-table__check { vertical-align: middle; }` rule into a shared stylesheet or CSS module and reuse the existing `policy-type-table` class or a new className for scoping.
- The wrapper `<div className="policy-type-table">` is currently only used to host the inline `<style>` tag; once the styling is moved to a stylesheet, consider removing the wrapper to avoid unnecessary DOM nesting unless you need it for layout.
- You are now setting vertical alignment both via the `.pf-v6-c-table__check` rule and `tableBodyProps={{ style: { verticalAlign: 'middle' } }}`; consider consolidating to a single, clearly scoped approach to avoid confusion and potential style conflicts.

## Individual Comments

### Comment 1
<location path="src/PresentationalComponents/PolicyTypesTable/PolicyTypeTable.js" line_range="32-33" />
<code_context>
-            label: 'Policy name',
-            filterAttribute: 'title',
+    <div className="policy-type-table">
+      <style>
+        {`
+          .pf-v6-c-table__check {
+            vertical-align: middle;
</code_context>
<issue_to_address>
**suggestion:** Avoid defining a <style> tag inside the component to prevent duplicated global CSS on each render.

Because this `<style>` tag lives inside the component, the same CSS is injected on every mount and the `.pf-v6-c-table__check` rule is applied globally. Please move this rule into a shared stylesheet (or CSS-in-JS) and scope it with `.policy-type-table .pf-v6-c-table__check` so it only affects this table.

Suggested implementation:

```javascript
    <div className="policy-type-table">
      <TableToolsTable

```

1. Create or update a stylesheet for this component (for example `src/PresentationalComponents/PolicyTypesTable/PolicyTypeTable.scss` or `.css`) and add:

   ```css
   .policy-type-table .pf-v6-c-table__check {
     vertical-align: middle;
   }
   ```

2. Import that stylesheet in `PolicyTypeTable.js` near the other imports, following the existing convention in this codebase. For example, if SCSS is used:

   ```js
   import './PolicyTypeTable.scss';
   ```

3. Ensure the build setup is configured to process the chosen stylesheet type (CSS/SCSS), consistent with how other presentational components in the project are styled.
</issue_to_address>

### Comment 2
<location path="src/PresentationalComponents/PolicyTypesTable/PolicyTypeTable.js" line_range="60-68" />
<code_context>
+          emptyRows: emptyRows('policy types', columns.length),
+        }}
+        variant="compact"
+        tableBodyProps={{ style: { verticalAlign: 'middle' } }}
+      />
+    </div>
</code_context>
<issue_to_address>
**suggestion:** Unify the vertical alignment approach to avoid overlapping sources of truth.

There’s now both a CSS rule for `.pf-v6-c-table__check` and an inline `tableBodyProps` style (`verticalAlign: 'middle'`). Please pick one approach (ideally the CSS rule) to avoid maintaining two potentially conflicting alignment settings.

```suggestion
        options={{
          detailsComponent: PolicyTypeDetailsRow,
          onRadioSelect: (_event, _value, _rowIdx, { item: { itemId } }) =>
            onChange && onChange(profiles.find(({ id }) => id === itemId)),
          emptyRows: emptyRows('policy types', columns.length),
        }}
        variant="compact"
      />
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +32 to +33
<style>
{`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid defining a <style> tag inside the component to prevent duplicated global CSS on each render.

Because this <style> tag lives inside the component, the same CSS is injected on every mount and the .pf-v6-c-table__check rule is applied globally. Please move this rule into a shared stylesheet (or CSS-in-JS) and scope it with .policy-type-table .pf-v6-c-table__check so it only affects this table.

Suggested implementation:

    <div className="policy-type-table">
      <TableToolsTable
  1. Create or update a stylesheet for this component (for example src/PresentationalComponents/PolicyTypesTable/PolicyTypeTable.scss or .css) and add:

    .policy-type-table .pf-v6-c-table__check {
      vertical-align: middle;
    }
  2. Import that stylesheet in PolicyTypeTable.js near the other imports, following the existing convention in this codebase. For example, if SCSS is used:

    import './PolicyTypeTable.scss';
  3. Ensure the build setup is configured to process the chosen stylesheet type (CSS/SCSS), consistent with how other presentational components in the project are styled.

Comment on lines +60 to +68
options={{
detailsComponent: PolicyTypeDetailsRow,
onRadioSelect: (_event, _value, _rowIdx, { item: { itemId } }) =>
onChange && onChange(profiles.find(({ id }) => id === itemId)),
emptyRows: emptyRows('policy types', columns.length),
}}
variant="compact"
tableBodyProps={{ style: { verticalAlign: 'middle' } }}
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Unify the vertical alignment approach to avoid overlapping sources of truth.

There’s now both a CSS rule for .pf-v6-c-table__check and an inline tableBodyProps style (verticalAlign: 'middle'). Please pick one approach (ideally the CSS rule) to avoid maintaining two potentially conflicting alignment settings.

Suggested change
options={{
detailsComponent: PolicyTypeDetailsRow,
onRadioSelect: (_event, _value, _rowIdx, { item: { itemId } }) =>
onChange && onChange(profiles.find(({ id }) => id === itemId)),
emptyRows: emptyRows('policy types', columns.length),
}}
variant="compact"
tableBodyProps={{ style: { verticalAlign: 'middle' } }}
/>
options={{
detailsComponent: PolicyTypeDetailsRow,
onRadioSelect: (_event, _value, _rowIdx, { item: { itemId } }) =>
onChange && onChange(profiles.find(({ id }) => id === itemId)),
emptyRows: emptyRows('policy types', columns.length),
}}
variant="compact"
/>

@bastilian

Copy link
Copy Markdown
Member

@opacut In general we should avoid inline style tags, this can mess very badly with other things. We should also not attempt to bodge-fix this and first figure out why there is a misalignment in the TableToolsTable and fix it there, so others benefit from it as well.

@opacut opacut marked this pull request as draft June 2, 2026 06:22
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@opacut

opacut commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Decided to solve instead with a pr to patternfly-react: patternfly/patternfly-react#12451

@opacut opacut closed this Jun 12, 2026
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.

2 participants