@linzjs/step-ag-grid 32.7.1 → 34.0.0

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.
Files changed (66) hide show
  1. package/dist/src/components/PostSortRowsHook.test.d.ts +1 -0
  2. package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
  3. package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
  4. package/dist/src/utils/__tests__/storybookTestUtil.ts +1 -1
  5. package/dist/step-ag-grid.cjs +190 -206
  6. package/dist/step-ag-grid.cjs.map +1 -1
  7. package/dist/step-ag-grid.esm.js +190 -206
  8. package/dist/step-ag-grid.esm.js.map +1 -1
  9. package/package.json +17 -17
  10. package/src/components/Grid.tsx +8 -10
  11. package/src/components/PostSortRowsHook.test.ts +300 -0
  12. package/src/components/PostSortRowsHook.ts +127 -24
  13. package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
  14. package/src/components/gridForm/GridFormTextInput.tsx +2 -1
  15. package/src/components/gridHook/useGridRangeSelection.ts +8 -6
  16. package/src/contexts/GridContextProvider.tsx +5 -9
  17. package/src/react-menu3/components/ControlledMenu.tsx +5 -3
  18. package/src/react-menu3/components/MenuList.tsx +7 -3
  19. package/src/react-menu3/hooks/useItems.ts +1 -1
  20. package/src/stories/components/ActionButton.stories.tsx +12 -11
  21. package/src/stories/decorators/withOpenInPanelDecorator.tsx +35 -0
  22. package/src/stories/grid/GridCopy.stories.tsx +38 -35
  23. package/src/stories/grid/GridDragRow.stories.tsx +41 -36
  24. package/src/stories/grid/GridFilterButtons.stories.tsx +25 -19
  25. package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +42 -37
  26. package/src/stories/grid/GridInlineText.stories.tsx +62 -49
  27. package/src/stories/grid/GridNoRowsOverlay.stories.tsx +28 -23
  28. package/src/stories/grid/GridNonEditableRow.stories.tsx +30 -24
  29. package/src/stories/grid/GridPinnedRow.stories.tsx +37 -31
  30. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +29 -24
  31. package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +89 -82
  32. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +27 -22
  33. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +29 -24
  34. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +30 -25
  35. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +29 -24
  36. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +29 -24
  37. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -24
  38. package/src/stories/grid/GridReadOnly.stories.tsx +56 -52
  39. package/src/stories/grid/GridSorting.stories.tsx +498 -86
  40. package/src/stories/grid/GridViewList.stories.tsx +31 -26
  41. package/src/stories/grid/GridViewSelectableList.stories.tsx +31 -26
  42. package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +41 -37
  43. package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +40 -36
  44. package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +40 -36
  45. package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -6
  46. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +74 -74
  47. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +59 -59
  48. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +58 -58
  49. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +62 -62
  50. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +118 -118
  51. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +107 -105
  52. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +72 -64
  53. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +82 -73
  54. package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +12 -13
  55. package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +12 -13
  56. package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +11 -13
  57. package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +11 -13
  58. package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +11 -13
  59. package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +11 -13
  60. package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +11 -13
  61. package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +11 -13
  62. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +110 -107
  63. package/src/stories/react-menu/ReactMenu.stories.tsx +70 -73
  64. package/src/styles/GridLoadableCell.scss +1 -1
  65. package/src/utils/__tests__/storybookTestUtil.ts +1 -1
  66. package/src/utils/useSharedInterval.ts +3 -3
@@ -1,8 +1,4 @@
1
- import '../../../react-menu3/styles/index.scss';
2
- import '../../../styles/index.scss';
3
- import '@linzjs/lui/dist/scss/base.scss';
4
-
5
- import { StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
6
2
  import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
7
3
  import { useRef } from 'react';
8
4
  import { expect, fn, userEvent, within } from 'storybook/test';
@@ -16,12 +12,6 @@ import {
16
12
  wait,
17
13
  } from '../../..';
18
14
 
19
- export default {
20
- title: 'GridForm / Interactions',
21
- component: GridFormMultiSelect,
22
- args: {},
23
- };
24
-
25
15
  const updateValue = fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
26
16
 
27
17
  const onSave = fn();
@@ -76,111 +66,121 @@ const Template: StoryFn<typeof GridFormMultiSelect> = (props: GridFormMultiSelec
76
66
  );
77
67
  };
78
68
 
79
- export const GridFormMultiSelectInteractions_: typeof Template = Template.bind({});
80
- GridFormMultiSelectInteractions_.play = async ({ canvasElement }) => {
81
- updateValue.mockClear();
82
- onSave.mockClear();
83
- onSelectFilter.mockClear();
84
-
85
- const canvas = within(canvasElement);
86
-
87
- const getOption = (name: RegExp | string) => canvas.findByRole('menuitem', { name });
88
-
89
- // Check enabled menu handles click
90
- const zeroMenuOption = await getOption(/Zero/);
91
- expect(zeroMenuOption).toBeInTheDocument();
92
-
93
- await userEvent.click(zeroMenuOption);
94
- await userEvent.keyboard('{Tab}');
95
- expect(updateValue).toHaveBeenCalled();
96
- expect(onSave).toHaveBeenCalledWith({ selectedOptions: [options[0]], selectedRows: [] });
97
-
98
- // Check sub menu works
99
- const subTextInput = await getOption(/Sub component/);
100
- expect(subTextInput).toBeInTheDocument();
101
-
102
- expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
103
-
104
- await userEvent.click(subTextInput);
105
- const textInput = await canvas.findByPlaceholderText('Text input');
106
- expect(textInput).toBeInTheDocument();
107
- expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
108
-
109
- // textInput should be autofocus
110
- await userEvent.type(textInput, 'Hello');
111
- expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
112
-
113
- // Test tab to save
114
- updateValue.mockClear();
115
- onSave.mockClear();
116
- await userEvent.tab();
117
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
118
- expect(onSave).toHaveBeenCalledWith({
119
- selectedRows: [],
120
- selectedOptions: [
121
- { label: 'Zero', value: 0, checked: true },
122
- { label: 'Sub component', value: 2, checked: true, subValue: 'Hello', subComponent: expect.anything() },
123
- ],
124
- });
125
-
126
- // Test shift+tab to save
127
- updateValue.mockClear();
128
- onSave.mockClear();
129
- await userEvent.tab({ shift: true });
130
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
131
- expect(onSave).toHaveBeenCalled();
132
-
133
- // Test escape to not save
134
- updateValue.mockClear();
135
- onSave.mockClear();
136
- await userEvent.type(textInput, '{Escape}');
137
- // expect(updateValue).not.toHaveBeenCalled();
138
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
139
- expect(onSave).not.toHaveBeenCalled();
140
-
141
- // Test invalid value doesn't save
142
- updateValue.mockClear();
143
- onSave.mockClear();
144
- await userEvent.clear(textInput);
145
- await userEvent.type(textInput, '{Enter}');
146
- expect(updateValue).not.toHaveBeenCalled();
147
- expect(onSave).not.toHaveBeenCalled();
148
-
149
- // Test filter
150
- const filterText = await canvas.findByPlaceholderText('Filter...');
151
- await userEvent.type(filterText, 'o');
152
- await wait(500);
153
- expect(canvas.queryByText('One')).toBeInTheDocument();
154
- expect(canvas.queryByText('Other')).toBeInTheDocument();
155
- await userEvent.type(filterText, 'n');
156
- expect(canvas.queryByText('One')).toBeInTheDocument();
157
- expect(canvas.queryByText('Zero')).not.toBeInTheDocument();
158
- expect(canvas.queryByText('Sub component')).not.toBeInTheDocument();
159
- expect(canvas.queryByText('Other')).not.toBeInTheDocument();
160
-
161
- await userEvent.type(filterText, 'x');
162
- expect(canvas.queryByText('One')).not.toBeInTheDocument();
163
- expect(canvas.queryByText('No Options')).toBeInTheDocument();
164
-
165
- // Check enter works to add custom free-text
166
- await userEvent.type(filterText, '{Enter}');
167
- expect(onSelectFilter).toHaveBeenCalledWith({
168
- filter: 'onx',
169
- options: [
170
- {
171
- ...options[0],
172
- checked: true,
173
- },
174
- {
175
- ...options[1],
176
- },
177
- {
178
- ...options[2],
179
- checked: true,
180
- },
181
- {
182
- ...options[3],
183
- },
184
- ],
185
- });
69
+ const meta: Meta<typeof Template> = {
70
+ title: 'GridForm / Interactions',
71
+ component: Template,
72
+ args: {},
73
+ };
74
+ export default meta;
75
+
76
+ type Story = StoryObj<typeof meta>;
77
+
78
+ export const GridFormMultiSelectInteractions_: Story = {
79
+ play: async ({ canvasElement }) => {
80
+ updateValue.mockClear();
81
+ onSave.mockClear();
82
+ onSelectFilter.mockClear();
83
+
84
+ const canvas = within(canvasElement);
85
+
86
+ const getOption = (name: RegExp | string) => canvas.findByRole('menuitem', { name });
87
+
88
+ // Check enabled menu handles click
89
+ const zeroMenuOption = await getOption(/Zero/);
90
+ await expect(zeroMenuOption).toBeInTheDocument();
91
+
92
+ await userEvent.click(zeroMenuOption);
93
+ await userEvent.keyboard('{Tab}');
94
+ await expect(updateValue).toHaveBeenCalled();
95
+ await expect(onSave).toHaveBeenCalledWith({ selectedOptions: [options[0]], selectedRows: [] });
96
+
97
+ // Check sub menu works
98
+ const subTextInput = await getOption(/Sub component/);
99
+ await expect(subTextInput).toBeInTheDocument();
100
+
101
+ await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
102
+
103
+ await userEvent.click(subTextInput);
104
+ const textInput = await canvas.findByPlaceholderText('Text input');
105
+ await expect(textInput).toBeInTheDocument();
106
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
107
+
108
+ // textInput should be autofocus
109
+ await userEvent.type(textInput, 'Hello');
110
+ await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
111
+
112
+ // Test tab to save
113
+ updateValue.mockClear();
114
+ onSave.mockClear();
115
+ await userEvent.tab();
116
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
117
+ await expect(onSave).toHaveBeenCalledWith({
118
+ selectedRows: [],
119
+ selectedOptions: [
120
+ { label: 'Zero', value: 0, checked: true },
121
+ { label: 'Sub component', value: 2, checked: true, subValue: 'Hello', subComponent: expect.anything() },
122
+ ],
123
+ });
124
+
125
+ // Test shift+tab to save
126
+ updateValue.mockClear();
127
+ onSave.mockClear();
128
+ await userEvent.tab({ shift: true });
129
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
130
+ await expect(onSave).toHaveBeenCalled();
131
+
132
+ // Test escape to not save
133
+ updateValue.mockClear();
134
+ onSave.mockClear();
135
+ await userEvent.type(textInput, '{Escape}');
136
+ // expect(updateValue).not.toHaveBeenCalled();
137
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
138
+ await expect(onSave).not.toHaveBeenCalled();
139
+
140
+ // Test invalid value doesn't save
141
+ updateValue.mockClear();
142
+ onSave.mockClear();
143
+ await userEvent.clear(textInput);
144
+ await userEvent.type(textInput, '{Enter}');
145
+ await expect(updateValue).not.toHaveBeenCalled();
146
+ await expect(onSave).not.toHaveBeenCalled();
147
+
148
+ // Test filter
149
+ const filterText = await canvas.findByPlaceholderText('Filter...');
150
+ await userEvent.type(filterText, 'o');
151
+ await wait(500);
152
+ await expect(canvas.queryByText('One')).toBeInTheDocument();
153
+ await expect(canvas.queryByText('Other')).toBeInTheDocument();
154
+ await userEvent.type(filterText, 'n');
155
+ await expect(canvas.queryByText('One')).toBeInTheDocument();
156
+ await expect(canvas.queryByText('Zero')).not.toBeInTheDocument();
157
+ await expect(canvas.queryByText('Sub component')).not.toBeInTheDocument();
158
+ await expect(canvas.queryByText('Other')).not.toBeInTheDocument();
159
+
160
+ await userEvent.type(filterText, 'x');
161
+ await expect(canvas.queryByText('One')).not.toBeInTheDocument();
162
+ await expect(canvas.queryByText('No Options')).toBeInTheDocument();
163
+
164
+ // Check enter works to add custom free-text
165
+ await userEvent.type(filterText, '{Enter}');
166
+ await expect(onSelectFilter).toHaveBeenCalledWith({
167
+ filter: 'onx',
168
+ options: [
169
+ {
170
+ ...options[0],
171
+ checked: true,
172
+ },
173
+ {
174
+ ...options[1],
175
+ },
176
+ {
177
+ ...options[2],
178
+ checked: true,
179
+ },
180
+ {
181
+ ...options[3],
182
+ },
183
+ ],
184
+ });
185
+ },
186
186
  };
@@ -1,8 +1,4 @@
1
- import '../../../react-menu3/styles/index.scss';
2
- import '../../../styles/index.scss';
3
- import '@linzjs/lui/dist/scss/base.scss';
4
-
5
- import { StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
6
2
  import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
7
3
  import { useRef } from 'react';
8
4
  import * as test from 'storybook/test';
@@ -17,12 +13,6 @@ import {
17
13
  PopoutMenuSeparator,
18
14
  } from '../../..';
19
15
 
20
- export default {
21
- title: 'GridForm / Interactions',
22
- component: GridFormPopoverMenu,
23
- args: {},
24
- };
25
-
26
16
  const updateValue = test.fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) =>
27
17
  saveFn([]),
28
18
  );
@@ -82,93 +72,103 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
82
72
  );
83
73
  };
84
74
 
85
- export const GridFormPopoverMenuInteractions_: typeof Template = Template.bind({});
86
- GridFormPopoverMenuInteractions_.play = async ({ canvasElement }) => {
87
- const canvas = within(canvasElement);
88
-
89
- const getOption = (name: string) => canvas.findByRole('menuitem', { name });
90
-
91
- const enabledMenuOption = await getOption('Enabled');
92
- expect(enabledMenuOption).toBeInTheDocument();
93
- await userEvent.click(enabledMenuOption);
94
- expect(enabledAction).toHaveBeenCalled();
95
-
96
- enabledAction.mockClear();
97
- const disabledMenuOption = await getOption('Disabled');
98
- expect(disabledMenuOption).toBeInTheDocument();
99
- await userEvent.click(disabledMenuOption);
100
- expect(disabledAction).not.toHaveBeenCalled();
101
-
102
- // Sub input tests
103
- const subTextInput = await getOption('Sub text input');
104
- expect(subTextInput).toBeInTheDocument();
105
- expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
106
-
107
- const subTextArea = await getOption('Sub text area');
108
- expect(subTextArea).toBeInTheDocument();
109
- expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
110
-
111
- await userEvent.click(subTextInput);
112
- const textInput = await canvas.findByPlaceholderText('Text input');
113
- expect(textInput).toBeInTheDocument();
114
- expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
115
- expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
116
-
117
- await userEvent.type(textInput, 'Hello');
118
- expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
119
-
120
- // Test tab to save
121
- updateValue.mockClear();
122
- await userEvent.tab();
123
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
124
-
125
- // Test shift+tab to save
126
- updateValue.mockClear();
127
- await userEvent.tab({ shift: true });
128
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
129
-
130
- // Test escape to not save
131
- updateValue.mockClear();
132
- await userEvent.type(textInput, '{Escape}');
133
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
134
-
135
- // Test invalid value doesn't save
136
- updateValue.mockClear();
137
- await userEvent.clear(textInput);
138
- await userEvent.type(textInput, '{Enter}');
139
- expect(updateValue).not.toHaveBeenCalled();
140
-
141
- // Sub text area tests
142
- subTextArea.click();
143
-
144
- const textArea = await canvas.findByPlaceholderText('Text area');
145
- expect(textArea).toBeInTheDocument();
146
- expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
147
- expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
148
-
149
- await userEvent.type(textArea, 'Hello');
150
- expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
151
-
152
- // Test tab to save
153
- updateValue.mockClear();
154
- await userEvent.tab();
155
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
156
-
157
- // Test shift+tab to save
158
- updateValue.mockClear();
159
- await userEvent.tab({ shift: true });
160
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
161
-
162
- // Test escape to not save
163
- updateValue.mockClear();
164
- await userEvent.type(textArea, '{Escape}');
165
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
166
-
167
- // Test invalid value doesn't save
168
- updateValue.mockClear();
169
- await userEvent.clear(textArea);
170
- await userEvent.type(textArea, '{Enter}');
171
- expect(updateValue).not.toHaveBeenCalled();
75
+ const meta: Meta<typeof Template> = {
76
+ title: 'GridForm / Interactions',
77
+ component: Template,
78
+ args: {},
79
+ };
80
+ export default meta;
81
+
82
+ type Story = StoryObj<typeof meta>;
83
+
84
+ export const GridFormPopoverMenuInteractions_: Story = {
85
+ play: async ({ canvasElement }) => {
86
+ const canvas = within(canvasElement);
87
+
88
+ const getOption = (name: string) => canvas.findByRole('menuitem', { name });
89
+
90
+ const enabledMenuOption = await getOption('Enabled');
91
+ await expect(enabledMenuOption).toBeInTheDocument();
92
+ await userEvent.click(enabledMenuOption);
93
+ await expect(enabledAction).toHaveBeenCalled();
94
+
95
+ enabledAction.mockClear();
96
+ const disabledMenuOption = await getOption('Disabled');
97
+ await expect(disabledMenuOption).toBeInTheDocument();
98
+ await userEvent.click(disabledMenuOption);
99
+ await expect(disabledAction).not.toHaveBeenCalled();
100
+
101
+ // Sub input tests
102
+ const subTextInput = await getOption('Sub text input');
103
+ await expect(subTextInput).toBeInTheDocument();
104
+ await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
105
+
106
+ const subTextArea = await getOption('Sub text area');
107
+ await expect(subTextArea).toBeInTheDocument();
108
+ await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
109
+
110
+ await userEvent.click(subTextInput);
111
+ const textInput = await canvas.findByPlaceholderText('Text input');
112
+ await expect(textInput).toBeInTheDocument();
113
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
114
+ await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
115
+
116
+ await userEvent.type(textInput, 'Hello');
117
+ await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
118
+
119
+ // Test tab to save
120
+ updateValue.mockClear();
121
+ await userEvent.tab();
122
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
123
+
124
+ // Test shift+tab to save
125
+ updateValue.mockClear();
126
+ await userEvent.tab({ shift: true });
127
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
128
+
129
+ // Test escape to not save
130
+ updateValue.mockClear();
131
+ await userEvent.type(textInput, '{Escape}');
132
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
133
+
134
+ // Test invalid value doesn't save
135
+ updateValue.mockClear();
136
+ await userEvent.clear(textInput);
137
+ await userEvent.type(textInput, '{Enter}');
138
+ await expect(updateValue).not.toHaveBeenCalled();
139
+
140
+ // Sub text area tests
141
+ subTextArea.click();
142
+
143
+ const textArea = await canvas.findByPlaceholderText('Text area');
144
+ await expect(textArea).toBeInTheDocument();
145
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
146
+ await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
147
+
148
+ await userEvent.type(textArea, 'Hello');
149
+ await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
150
+
151
+ // Test tab to save
152
+ updateValue.mockClear();
153
+ await userEvent.tab();
154
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
155
+
156
+ // Test shift+tab to save
157
+ updateValue.mockClear();
158
+ await userEvent.tab({ shift: true });
159
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
160
+
161
+ // Test escape to not save
162
+ updateValue.mockClear();
163
+ await userEvent.type(textArea, '{Escape}');
164
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
165
+
166
+ // Test invalid value doesn't save
167
+ updateValue.mockClear();
168
+ await userEvent.clear(textArea);
169
+ await userEvent.type(textArea, '{Enter}');
170
+ await expect(updateValue).not.toHaveBeenCalled();
171
+ },
172
172
  };
173
173
 
174
174
  const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMenuProps<any>) => {
@@ -209,11 +209,13 @@ const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormP
209
209
  // Regression test: when every option resolves to hidden, the menu must show "No actions"
210
210
  // rather than an empty menu body (isEmpty(options) alone doesn't catch this — the array is
211
211
  // non-empty, just every item is hidden).
212
- export const GridFormPopoverMenuAllOptionsHidden_ = AllHiddenTemplate.bind({});
213
- GridFormPopoverMenuAllOptionsHidden_.play = async ({ canvasElement }) => {
214
- const canvas = within(canvasElement);
215
-
216
- expect(await canvas.findByText('No actions')).toBeInTheDocument();
217
- expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
218
- expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
212
+ export const GridFormPopoverMenuAllOptionsHidden_: Story = {
213
+ render: AllHiddenTemplate,
214
+ play: async ({ canvasElement }) => {
215
+ const canvas = within(canvasElement);
216
+
217
+ await expect(await canvas.findByText('No actions')).toBeInTheDocument();
218
+ await expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
219
+ await expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
220
+ },
219
221
  };