Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/aggrid/src/aggrid-ix-theme-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
export const aggridIxThemeParams = {
accentColor: `var(--theme-color-focus-bdr)`,
backgroundColor: `var(--theme-color-2)`,
backgroundColor: `var(--theme-color-1)`,
headerColumnResizeHandleColor: `var(--theme-color-0)`,
foregroundColor: `var(--theme-color-std-text)`,
cellTextColor: `var(--theme-color-std-text)`,
Expand All @@ -25,7 +25,7 @@ export const aggridIxThemeParams = {
borderColor: `var(--theme-color-x-weak-bdr)`,
headerBackgroundColor: `var(--theme-color-2)`,
tooltipBackgroundColor: `var(--theme-color-2)`,
oddRowBackgroundColor: `var(--theme-color-ghost-alt)`,
oddRowBackgroundColor: `var(--theme-color-2)`,
sideBarBackgroundColor: `var(--theme-color-2)`,
invalidColor: `var(--theme-color-alarm)`,
checkboxUncheckedBorderColor: `var(--theme-color-contrast-bdr)`,
Expand Down Expand Up @@ -98,7 +98,6 @@ export const aggridIxThemeParams = {
sideButtonsBarBackgroundColor: `var(--theme-color-2)`,
sideButtonHoverBackgroundColor: `var(--theme-color-ghost--hover)`,
checkboxCheckedShapeColor: `var(--theme-color-primary--contrast)`,
OddRowBackgroundColor: `var(--theme-color-ghost-alt)`,
tabBackgroundColor: `rgba(255, 255, 255, 0)`,
tabBorderColor: `rgba(24, 29, 31, 0.15)`,
tabHoverBackgroundColor: `rgba(255, 255, 255, 0)`,
Expand Down
8 changes: 8 additions & 0 deletions packages/aggrid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import headerStyles from './header.style.css';
import tooltipStyles from './tooltip.style.css';
import radioStyles from './radio.style.css';
import inputStyles from './input.style.css';
import rowStateStyles from './row-state.style.css';
import { aggridIxThemeParams } from './aggrid-ix-theme-params.ts';
import { iconOverrides } from 'ag-grid-community';
import {
Expand Down Expand Up @@ -106,6 +107,13 @@ function createIxTheme(agModule: AgGridModule) {
css: inputStyles,
})
)
.withPart(
createPart({
feature: 'rowStateCustomStyles',
params: {},
css: rowStateStyles,
})
)
.withPart(
createPart({
feature: 'iconOverrides',
Expand Down
15 changes: 15 additions & 0 deletions packages/aggrid/src/row-state.style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2025 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

.ag-row.ag-row-hover .ag-cell {
background-image: linear-gradient(
var(--theme-color-ghost--hover),
var(--theme-color-ghost--hover)
) !important;
}
Comment on lines +10 to +15

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using background-image: linear-gradient(...) !important to apply the hover overlay will completely override any custom background-image (such as icons, custom gradients, or patterns) that might be set on cells by custom cell renderers or other styles.

To avoid overriding cell background images while still achieving the desired overlay effect, you can use an inset box-shadow instead. An inset box-shadow overlays on top of both background-color and background-image without replacing them.

Additionally, since we are manually painting the hover overlay on the cell, please ensure that AG Grid's built-in rowHoverColor parameter in aggrid-ix-theme-params.ts is set to transparent (or rgba(0, 0, 0, 0)) to prevent AG Grid from rendering its own hover overlay simultaneously, which would result in double-hover tinting.

.ag-row.ag-row-hover .ag-cell {
  box-shadow: inset 0 0 0 9999px var(--theme-color-ghost--hover) !important;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

rowHoverColor is intentionally retained; it and the cell tint layer together to produce consistent hover across zebra rows. Removing it regresses odd/even consistency.
The box-shadow: inset approach produces per-cell border seams, so it's not suitable here.

2 changes: 2 additions & 0 deletions packages/storybook-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"dependencies": {
"@maskito/core": "^3.2.0",
"@maskito/kit": "^3.2.0",
"ag-grid-community": "^33.3.2",
"lit": "^3.2.1"
},
"devDependencies": {
"@siemens/ix": "workspace:*",
"@siemens/ix-aggrid": "workspace:*",
"@siemens/ix-icons": "catalog:",
"@stencil/core": "~4.17.0",
"@storybook/addon-a11y": "^10.1.11",
Expand Down
111 changes: 111 additions & 0 deletions packages/storybook-docs/src/stories/aggrid.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* SPDX-FileCopyrightText: 2024 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Meta, StoryObj } from '@storybook/web-components-vite';
import { getIxTheme } from '@siemens/ix-aggrid';
import * as agGridCommunity from 'ag-grid-community';
import {
AllCommunityModule,
ModuleRegistry,
createGrid,
type GridOptions,
} from 'ag-grid-community';

ModuleRegistry.registerModules([AllCommunityModule]);

type AgGridArgs = {
gridOptions: GridOptions;
};

const rowData = [
{ type: 'Equipment', status: 'Normal', hwVersion: '2.0' },
{ type: 'Positioner', status: 'Maintenance', hwVersion: '1.0' },
{ type: 'Pressure sensor', status: 'Unknown', hwVersion: 'N/A' },
{ type: 'Flow meter', status: 'Normal', hwVersion: '3.1' },
{ type: 'Temperature sensor', status: 'Warning', hwVersion: '2.2' },
{ type: 'Valve', status: 'Normal', hwVersion: '1.5' },
{ type: 'Actuator', status: 'Maintenance', hwVersion: '2.0' },
{ type: 'Controller', status: 'Normal', hwVersion: '4.0' },
{ type: 'Safety relay', status: 'Unknown', hwVersion: 'N/A' },
{ type: 'Power supply', status: 'Normal', hwVersion: '1.8' },
];

function renderGrid(args: AgGridArgs) {
const container = document.createElement('div');
container.style.height = '20rem';
container.style.width = '100%';

createGrid(container, {
...args.gridOptions,
theme: getIxTheme(agGridCommunity),
});

return container;
}
Comment on lines +38 to +49

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Store grid API and call destroy() on re-render to prevent leaks.

createGrid returns a GridApi with a destroy() method. Without storing and destroying the previous instance, Storybook re-renders (arg changes, story switching) will leak grid instances — event listeners, timers, and DOM observers remain active. This degrades Storybook performance over time.

♻️ Proposed fix to add grid cleanup
+let gridApi: ReturnType<typeof createGrid> | null = null;
+
 function renderGrid(args: AgGridArgs) {
+  if (gridApi) {
+    gridApi.destroy();
+    gridApi = null;
+  }
   const container = document.createElement('div');
   container.style.height = '20rem';
   container.style.width = '100%';
 
-  createGrid(container, {
+  gridApi = createGrid(container, {
     ...args.gridOptions,
     theme: getIxTheme(agGridCommunity),
   });
 
   return container;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function renderGrid(args: AgGridArgs) {
const container = document.createElement('div');
container.style.height = '20rem';
container.style.width = '100%';
createGrid(container, {
...args.gridOptions,
theme: getIxTheme(agGridCommunity),
});
return container;
}
let gridApi: ReturnType<typeof createGrid> | null = null;
function renderGrid(args: AgGridArgs) {
if (gridApi) {
gridApi.destroy();
gridApi = null;
}
const container = document.createElement('div');
container.style.height = '20rem';
container.style.width = '100%';
gridApi = createGrid(container, {
...args.gridOptions,
theme: getIxTheme(agGridCommunity),
});
return container;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/storybook-docs/src/stories/aggrid.stories.ts` around lines 38 - 49,
Update renderGrid to retain the GridApi returned by createGrid and destroy the
previously stored grid instance before creating a replacement. Ensure cleanup
occurs on each re-render while preserving the existing container setup and grid
options.


const meta = {
title: 'Example/AgGrid',
tags: [],
render: (args) => renderGrid(args),
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/r2nqdNNXXZtPmWuVjIlM1Q/iX-Components---Brand-Dark?node-id=86777-15993&m=dev',
},
},
} satisfies Meta<AgGridArgs>;

export default meta;
type Story = StoryObj<AgGridArgs>;

export const Default: Story = {
args: {
gridOptions: {
rowDragManaged: true,
tooltipShowDelay: 500,
rowSelection: {
mode: 'multiRow',
checkboxes: true,
headerCheckbox: true,
selectAll: 'filtered',
},
columnDefs: [
{
field: 'type',
headerName: 'Type',
resizable: true,
rowDrag: true,
tooltipField: 'type',
},
{
field: 'status',
headerName: 'Status',
resizable: true,
sortable: true,
filter: true,
tooltipValueGetter: (params) =>
`Status: ${params.value} - Type: ${params.data.type}`,
},
{
field: 'hwVersion',
headerName: 'HW version',
resizable: true,
tooltipValueGetter: (params) =>
params.value === 'N/A'
? 'Hardware version not available'
: `Hardware Version ${params.value}`,
},
],
autoSizeStrategy: {
type: 'fitGridWidth',
},
rowData,
suppressCellFocus: true,
},
},
};
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading