8000 fix(Table): incorrect grid template column on uncollapse by axel7083 · Pull Request #13496 · podman-desktop/podman-desktop · GitHub
[go: up one dir, main page]

Skip to content

Conversation

axel7083
Copy link
Contributor
@axel7083 axel7083 commented Aug 4, 2025

What does this PR do?

The current mechanism of computing the grid-template-column has some flaw: every time the DOM changes, it need to be re-applied.

An alternative (this PR) is to instead have a CSS property (named table-grid-table-columns), and update the grid-able css class to use it. Then we can easily set a css variable value using svelte, without having to update manually the DOM or use getElementsByClassName functions.

Screenshot / video of UI

table-grid-template-css.mp4

What issues does this PR fix or reference?

Fixes #13495

How to test this PR?

  • Tests are covering the bug fix or the new feature
  1. Go to containers page
  2. assert everything look goods
  3. try collpasing group of containers (E.g. pod / compose project)

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
@axel7083 axel7083 requested review from benoitf and a team as code owners August 4, 2025 12:39
@axel7083 axel7083 requested review from dgolovin, feloy and a team and removed request for a team August 4, 2025 12:39
Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @axel7083 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `packages/ui/src/lib/table/Table.svelte:143` </location>
<code_context>
-});
-
-function setGridColumns(): void {
+let gridTemplateColumns: string;
+$: {
   // section and checkbox columns
</code_context>

<issue_to_address>
gridTemplateColumns is not initialized and may be undefined on first render.

Initialize gridTemplateColumns to an empty string or a default value to prevent potential layout issues from it being undefined.
</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.

});
function setGridColumns(): void {
let gridTemplateColumns: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): gridTemplateColumns is not initialized and may be undefined on first render.

Initialize gridTemplateColumns to an empty string or a default value to prevent potential layout issues from it being undefined.

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
Copy link
Contributor
coderabbitai bot commented Aug 4, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This change refactors the way CSS grid column widths are managed in the table component. The imperative approach using DOM queries and direct style manipulation in the afterUpdate lifecycle hook has been replaced by a declarative approach using a reactive Svelte statement. The computed grid column widths are now set via a CSS custom property (--table-grid-table-columns) on the table container, and the relevant CSS class uses this variable for its grid-template-columns property. Corresponding test cases have been updated to check for the presence and correctness of this CSS variable rather than inline styles.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Refactor table grid column width management to use a CSS variable and Svelte reactive statement (#13495)
Remove imperative DOM manipulation and afterUpdate for grid column styles (#13495)
Update tests to verify CSS variable usage for grid columns (#13495)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e6cfbc and a7e963f.

📒 Files selected for processing (3)
  • packages/ui/src/lib/table/Table.spec.ts (2 hunks)
  • packages/ui/src/lib/table/Table.svelte (4 hunks)
  • packages/ui/src/lib/table/TestMultiTables.spec.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: unit tests / windows-2025
  • GitHub Check: smoke e2e tests (production)
  • GitHub Check: smoke e2e tests (development)
  • GitHub Check: macOS
🔇 Additional comments (9)
packages/ui/src/lib/table/Table.svelte (3)

4-4: LGTM! Declarative CSS approach is cleaner.

The use of a CSS custom property for grid template columns is a much better approach than imperative DOM manipulation.


12-12: LGTM! afterUpdate removal aligns with refactor.

Removing the afterUpdate import is correct since the component no longer needs lifecycle-based DOM manipulation.


190-196: LGTM! CSS variable application is correct.

The inline style properly applies the computed grid template columns via the CSS custom property. This approach ensures the grid layout updates reactively with Svelte's change detection.

packages/ui/src/lib/table/TestMultiTables.spec.ts (3)

21-21: LGTM! Unused import removed.

Correctly removed the unused within import after refactoring the test logic.


32-32: LGTM! Test updated to check CSS custom property.

The test now correctly validates the CSS custom property --table-grid-table-columns instead of inline styles, aligning with the refactored implementation.


42-45: LGTM! Expected values align with new grid calculation.

The expected grid template strings correctly include the fixed pixel widths (20px for section column + 5px spacer) alongside the fractional units, matching the new reactive calculation logic.

packages/ui/src/lib/table/Table.spec.ts (3)

388-388: LGTM! Test name reflects the new declarative approach.

The renamed test better describes what it's validating - proper CSS styling rather than DOM manipulation.


400-400: LGTM! Class validation aligns with CSS refactor.

Checking for the grid-table class is the correct approach since the component now uses CSS classes with variables instead of inline styles.


403-405: LGTM! CSS custom property validation is thorough.

The test properly validates that the table element has the CSS custom property set with the expected grid template string. The expected value correctly accounts for all column types and widths.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
codecov bot commented Aug 4, 2025
8000

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@axel7083 axel7083 merged commit 06c7345 into podman-desktop:main Aug 6, 2025
21 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.21.0 milestone Aug 6, 2025
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.

bug(Table): children are malformed when closing opening drawer
3 participants
0