Skip to content

fix(dashboards-ng): preserve auto-positioned widget layout on cancel#1885

Open
chintankavathia wants to merge 1 commit intomainfrom
fix/dashboards/widgets-not-restored-to-original-state
Open

fix(dashboards-ng): preserve auto-positioned widget layout on cancel#1885
chintankavathia wants to merge 1 commit intomainfrom
fix/dashboards/widgets-not-restored-to-original-state

Conversation

@chintankavathia
Copy link
Copy Markdown
Member

@chintankavathia chintankavathia commented Apr 16, 2026

When widgets without explicit x/y are added, GridStack auto-positions them. On cancel, restoring configs with undefined x/y caused GridStack to re-auto-position, potentially producing a different layout.

Capture resolved positions from the DOM into persistedWidgetInstances when widgets are first added, so cancel() restores the exact layout.

Steps to reproduce:

  1. Go to https://element.siemens.io/dashboards-demo/#/dashboard
  2. Click edit
  3. Reduce width of Pie Chart widget on second row
  4. Shift "Full Speed" gauge chart widget left so that this widget and pie chart widget are next to each other
  5. Click on cancel
  6. Observe layout. "Full Speed" widget moves to third row

Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to capture auto-resolved widget positions when they are first added to the grid, ensuring that a layout cancellation restores the exact positions. Feedback was provided regarding the performance of this implementation, specifically the potential for redundant DOM reads and array iterations during initial load. It was suggested to optimize the check by verifying if coordinates are actually missing and to use the editable() signal instead of the private editableInternal field to align with the project's style guide.

Comment thread projects/dashboards-ng/src/components/grid/si-grid.component.ts Outdated
When widgets without explicit x/y are added, GridStack auto-positions
them. On cancel, restoring configs with undefined x/y caused GridStack
to re-auto-position, potentially producing a different layout.

Capture resolved positions from the DOM into persistedWidgetInstances
when widgets are first added, so cancel() restores the exact layout.
@chintankavathia chintankavathia force-pushed the fix/dashboards/widgets-not-restored-to-original-state branch from 5cb0689 to b869511 Compare April 16, 2026 07:35
@chintankavathia chintankavathia marked this pull request as ready for review April 16, 2026 07:57
@chintankavathia chintankavathia requested review from a team as code owners April 16, 2026 07:57
@chintankavathia chintankavathia added the bug Something isn't working label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant