@linzjs/step-ag-grid 32.1.0 → 32.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/step-ag-grid.cjs +7 -2
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +7 -2
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +10 -3
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +22 -0
package/package.json
CHANGED
|
@@ -75,9 +75,16 @@ const BooleanCellRenderer = (props: CustomCellEditorProps) => {
|
|
|
75
75
|
if (isDisabled) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const cell: HTMLElement | null = eGridCell?.querySelector(
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const cell: HTMLElement | null = eGridCell?.querySelector(
|
|
79
|
+
'.ag-cell-focus .grid-edit-boolean input.ag-checkbox-input:not(:disabled)',
|
|
80
|
+
);
|
|
81
|
+
if (cell) {
|
|
82
|
+
// When you redraw a cell the activeElement moves to the cell div away from input
|
|
83
|
+
// Refocus here if the cell div is active back to the input
|
|
84
|
+
const activeElement = cell.ownerDocument.activeElement;
|
|
85
|
+
if (activeElement && activeElement.getAttribute('role') === 'gridcell' && activeElement !== cell) {
|
|
86
|
+
cell.focus();
|
|
87
|
+
}
|
|
81
88
|
}
|
|
82
89
|
});
|
|
83
90
|
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
primitiveToSelectOption,
|
|
19
19
|
wait,
|
|
20
20
|
} from '../..';
|
|
21
|
+
import { expect, userEvent, waitFor } from 'storybook/test';
|
|
22
|
+
|
|
21
23
|
import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
|
|
22
24
|
import { IFormTestRow } from './FormTest';
|
|
23
25
|
|
|
@@ -130,3 +132,23 @@ const GridPopoutEditBooleanTemplate: StoryFn<typeof Grid> = () => {
|
|
|
130
132
|
|
|
131
133
|
export const _EditBoolean = GridPopoutEditBooleanTemplate.bind({});
|
|
132
134
|
_EditBoolean.play = waitForGridReady;
|
|
135
|
+
|
|
136
|
+
export const _EditBooleanRetainsFocusAfterToggle = GridPopoutEditBooleanTemplate.bind({});
|
|
137
|
+
_EditBooleanRetainsFocusAfterToggle.play = async (context) => {
|
|
138
|
+
await waitForGridReady(context);
|
|
139
|
+
const { canvasElement } = context;
|
|
140
|
+
|
|
141
|
+
// Use bold2 (no async delay) so the redraw happens immediately
|
|
142
|
+
const getBoolInput = () =>
|
|
143
|
+
canvasElement.querySelector('.ag-cell[col-id="bold2"] input.ag-checkbox-input') as HTMLElement;
|
|
144
|
+
|
|
145
|
+
await userEvent.click(canvasElement.querySelector('.ag-cell[col-id="bold2"]') as HTMLElement);
|
|
146
|
+
await waitFor(() => expect(getBoolInput()).toHaveFocus(), { timeout: 500 });
|
|
147
|
+
|
|
148
|
+
// Space toggles the checkbox, which triggers redrawRows — ag-grid moves focus from the
|
|
149
|
+
// input to the cell div (role="gridcell"). The shared interval should detect this and restore focus.
|
|
150
|
+
await userEvent.keyboard(' ');
|
|
151
|
+
|
|
152
|
+
// Re-query the input each retry since redraw replaces the DOM node
|
|
153
|
+
await waitFor(() => expect(getBoolInput()).toHaveFocus(), { timeout: 500 });
|
|
154
|
+
};
|