Skip to content

Commit 971b57c

Browse files
committed
fix: use text input for number filter, type=number messes up with number parsing
1 parent 0f69360 commit 971b57c

File tree

9 files changed

+57
-58
lines changed

9 files changed

+57
-58
lines changed

packages/pluggableWidgets/datagrid-number-filter-web/CHANGELOG.md

+36-32
Original file line numberDiff line numberDiff line change
@@ -6,164 +6,168 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue with number filter not working in some locales
12+
913
## [2.9.1] - 2025-03-20
1014

1115
### Fixed
1216

13-
- We fixed an issue where non-adjustable default filters were overridden by personalization settings.
17+
- We fixed an issue where non-adjustable default filters were overridden by personalization settings.
1418

1519
## [2.8.4] - 2024-11-13
1620

1721
### Changed
1822

19-
- We improved type mismatch filter error message.
23+
- We improved type mismatch filter error message.
2024

2125
### Fixed
2226

23-
- We fixed an issue where onChange wouldn't triggered on empty or not empty filter.
27+
- We fixed an issue where onChange wouldn't triggered on empty or not empty filter.
2428

2529
### Breaking changes
2630

27-
- We improved accessibility for the filter type select button - the select menu shows on enter, space, and arrow keys.
31+
- We improved accessibility for the filter type select button - the select menu shows on enter, space, and arrow keys.
2832

2933
### Added
3034

31-
- We improved screen reader integration.
35+
- We improved screen reader integration.
3236

3337
## [2.8.3] - 2024-10-31
3438

3539
### Fixed
3640

37-
- We fixed an issue with grid wide filters not resetting.
41+
- We fixed an issue with grid wide filters not resetting.
3842

3943
## [2.8.2] - 2024-10-14
4044

4145
### Fixed
4246

43-
- We fixed an issue where filters wouldn't reset.
47+
- We fixed an issue where filters wouldn't reset.
4448

4549
## [2.8.1] - 2024-09-23
4650

4751
### Changed
4852

49-
- Widget maintenance.
53+
- Widget maintenance.
5054

5155
## [2.8.0] - 2024-09-20
5256

5357
### Breaking changes
5458

55-
- We removed "Group key" property.
59+
- We removed "Group key" property.
5660

5761
## [2.7.0] - 2024-09-13
5862

5963
### Changed
6064

61-
- Improved integration with parent widgets.
65+
- Improved integration with parent widgets.
6266

6367
### Added
6468

65-
- Group key -- a new setting to associate the filter with the group (see "Filter groups" in docs for more information).
69+
- Group key -- a new setting to associate the filter with the group (see "Filter groups" in docs for more information).
6670

6771
## [2.6.1] - 2024-08-15
6872

6973
### Fixed
7074

71-
- We fixed an issue with the filter unexpectedly focusing when combined with conditional visibility.
75+
- We fixed an issue with the filter unexpectedly focusing when combined with conditional visibility.
7276

7377
## [2.6.0] - 2024-06-19
7478

7579
### Added
7680

77-
- A new hook that subscribes the widget to `Set_Filter` action.
81+
- A new hook that subscribes the widget to `Set_Filter` action.
7882

7983
### Changed
8084

81-
- We update event listener for `Reset_Filter` to allow reset to default value.
85+
- We update event listener for `Reset_Filter` to allow reset to default value.
8286

8387
## [2.5.1] - 2024-04-30
8488

8589
### Fixed
8690

87-
- We resolved an issue where the default value was not working in certain cases.
91+
- We resolved an issue where the default value was not working in certain cases.
8892

8993
## [2.5.0] - 2024-03-27
9094

9195
### Added
9296

93-
- A new hook that subscribes the widget to external events.
97+
- A new hook that subscribes the widget to external events.
9498

9599
## [2.4.3] - 2023-10-13
96100

97101
### Fixed
98102

99-
- We removed redundant code to improve widget load time in the browser.
103+
- We removed redundant code to improve widget load time in the browser.
100104

101105
## [2.4.2] - 2023-06-21
102106

103107
### Fixed
104108

105-
- We fixed issue with initial filter condition.
109+
- We fixed issue with initial filter condition.
106110

107111
## [2.4.1] - 2023-05-26
108112

109113
### Changed
110114

111-
- We updated the light and dark icons and tiles for the widget.
115+
- We updated the light and dark icons and tiles for the widget.
112116

113-
- We changed colors in the structure mode preview for dark and light modes.
117+
- We changed colors in the structure mode preview for dark and light modes.
114118

115119
## [2.4.0] - 2023-05-01
116120

117121
### Fixed
118122

119-
- We fixed an issue with widget rendering and performance.
123+
- We fixed an issue with widget rendering and performance.
120124

121125
### Breaking changes
122126

123-
- We introduce a breaking change that affects how widget is reacting on default value changes. Starting with this version, widget use the default value attribute only as an initial value, and any further changes to the default value attribute will be ignored.
127+
- We introduce a breaking change that affects how widget is reacting on default value changes. Starting with this version, widget use the default value attribute only as an initial value, and any further changes to the default value attribute will be ignored.
124128

125129
## [2.3.1] - 2022-08-11
126130

127131
### Fixed
128132

129-
- We fixed an issue with sync of widget defaultValue property and current filter value (#151789)
133+
- We fixed an issue with sync of widget defaultValue property and current filter value (#151789)
130134

131135
## [2.3.0] - 2022-05-11
132136

133137
### Added
134138

135-
- We added the options to filter for empty and non-empty values.
139+
- We added the options to filter for empty and non-empty values.
136140

137141
## [2.2.0] - 2021-12-23
138142

139143
### Added
140144

141-
- We added dark mode to Structure mode preview.
145+
- We added dark mode to Structure mode preview.
142146

143-
- We added dark icons for Tile and List view.
147+
- We added dark icons for Tile and List view.
144148

145149
## [2.0.2] - 2021-10-13
146150

147151
### Added
148152

149-
- We added the possibility to store the filter value in an attribute and trigger an onChange event on every filter change.
153+
- We added the possibility to store the filter value in an attribute and trigger an onChange event on every filter change.
150154

151-
- We added a "Enable advanced options" toggle for Studio users.
155+
- We added a "Enable advanced options" toggle for Studio users.
152156

153157
## [2.0.1] - 2021-10-07
154158

155159
### Fixed
156160

157-
- We fixed an issue where widgets get duplicate identifiers assigned under certain circumstances which causes inconsistencies in accessibility.
161+
- We fixed an issue where widgets get duplicate identifiers assigned under certain circumstances which causes inconsistencies in accessibility.
158162

159163
## [2.0.0] - 2021-09-28
160164

161165
### Added
162166

163-
- We added the possibility to reuse the filter with Gallery.
167+
- We added the possibility to reuse the filter with Gallery.
164168

165-
- We added a toolbox category and toolbox tile image for Studio & Studio Pro.
169+
- We added a toolbox category and toolbox tile image for Studio & Studio Pro.
166170

167171
### Changed
168172

169-
- We renamed the widget to Number filter.
173+
- We renamed the widget to Number filter.

packages/pluggableWidgets/datagrid-number-filter-web/src/DatagridNumberFilter.editorPreview.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function Preview(props: DatagridNumberFilterPreviewProps): ReactElement {
2727
screenReaderButtonCaption={props.screenReaderButtonCaption}
2828
screenReaderInputCaption={props.screenReaderInputCaption}
2929
styles={parseStyle(props.style)}
30-
type="text"
3130
/>
3231
);
3332
}

packages/pluggableWidgets/datagrid-number-filter-web/src/components/NumberFilterContainer.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function Container(props: ContainerProps): React.ReactElement {
6969
screenReaderInputCaption={props.screenReaderInputCaption?.value}
7070
styles={props.style}
7171
tabIndex={props.tabIndex}
72-
type="number"
7372
/>
7473
);
7574
}

packages/pluggableWidgets/datagrid-number-filter-web/src/components/__tests__/DatagridNumberFilter.spec.tsx

+18-18
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe("Number Filter", () => {
9393
render(<DatagridNumberFilter {...commonProps} onChange={action} valueAttribute={attribute} />);
9494

9595
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
96-
await user.type(screen.getByRole("spinbutton"), "10");
96+
await user.type(screen.getByRole("textbox"), "10");
9797

9898
act(() => {
9999
jest.runOnlyPendingTimers();
@@ -108,8 +108,8 @@ describe("Number Filter", () => {
108108
const { getByRole } = render(<DatagridNumberFilter {...commonProps} valueAttribute={attribute} />);
109109

110110
// First set a value
111-
const input = getByRole("spinbutton");
112-
expect(input).toHaveValue(null);
111+
const input = getByRole("textbox");
112+
expect(input).toHaveValue("");
113113

114114
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
115115
await user.type(input, "42");
@@ -127,31 +127,31 @@ describe("Number Filter", () => {
127127
plugin.emit("datagrid1", "reset.value", false);
128128
});
129129

130-
expect(input).toHaveValue(null);
130+
expect(input).toHaveValue("");
131131
expect(attribute.setValue).toHaveBeenLastCalledWith(undefined);
132132
});
133133

134134
describe("with defaultValue", () => {
135135
it("initializes with defaultValue", () => {
136136
render(<DatagridNumberFilter {...commonProps} defaultValue={dynamicValue<Big>(new Big(100))} />);
137-
expect(screen.getByRole("spinbutton")).toHaveValue(100);
137+
expect(screen.getByRole("textbox")).toHaveValue("100");
138138
});
139139

140140
it("do not sync value and defaultValue when defaultValue changes from undefined to number", () => {
141141
const { rerender } = render(<DatagridNumberFilter {...commonProps} defaultValue={undefined} />);
142-
expect(screen.getByRole("spinbutton")).toHaveValue(null);
142+
expect(screen.getByRole("textbox")).toHaveValue("");
143143
rerender(<DatagridNumberFilter {...commonProps} defaultValue={dynamicValue<Big>(new Big(100))} />);
144-
expect(screen.getByRole("spinbutton")).toHaveValue(null);
144+
expect(screen.getByRole("textbox")).toHaveValue("");
145145
});
146146

147147
it("do not sync value and defaultValue when defaultValue changes from number to undefined", async () => {
148148
const { rerender } = render(
149149
<DatagridNumberFilter {...commonProps} defaultValue={dynamicValue<Big>(new Big(100))} />
150150
);
151-
expect(screen.getByRole("spinbutton")).toHaveValue(100);
151+
expect(screen.getByRole("textbox")).toHaveValue("100");
152152
rerender(<DatagridNumberFilter {...commonProps} defaultValue={undefined} />);
153153
await waitFor(() => {
154-
expect(screen.getByRole("spinbutton")).toHaveValue(100);
154+
expect(screen.getByRole("textbox")).toHaveValue("100");
155155
});
156156
});
157157

@@ -162,8 +162,8 @@ describe("Number Filter", () => {
162162
<DatagridNumberFilter {...commonProps} valueAttribute={attribute} defaultValue={value} />
163163
);
164164

165-
const input = getByRole("spinbutton");
166-
expect(input).toHaveValue(123);
165+
const input = getByRole("textbox");
166+
expect(input).toHaveValue("123");
167167

168168
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
169169
// set input empty
@@ -182,7 +182,7 @@ describe("Number Filter", () => {
182182
plugin.emit("datagrid1", "reset.value", true);
183183
});
184184

185-
expect(input).toHaveValue(123);
185+
expect(input).toHaveValue("123");
186186
expect(attribute.setValue).toHaveBeenLastCalledWith(Big(123));
187187
});
188188
});
@@ -241,8 +241,8 @@ describe("Number Filter", () => {
241241
const attribute = new EditableValueBuilder<Big>().build();
242242
const { getByRole } = render(<DatagridNumberFilter {...commonProps} valueAttribute={attribute} />);
243243

244-
const input = getByRole("spinbutton");
245-
expect(input).toHaveValue(null);
244+
const input = getByRole("textbox");
245+
expect(input).toHaveValue("");
246246

247247
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
248248
await user.type(input, "42");
@@ -258,16 +258,16 @@ describe("Number Filter", () => {
258258
plugin.emit("datagrid1", "reset.value", false);
259259
});
260260

261-
expect(input).toHaveValue(null);
261+
expect(input).toHaveValue("");
262262
expect(attribute.setValue).toHaveBeenLastCalledWith(undefined);
263263
});
264264

265265
it("set value when external set value event is triggered", async () => {
266266
const attribute = new EditableValueBuilder<Big>().build();
267267
const { getByRole } = render(<DatagridNumberFilter {...commonProps} valueAttribute={attribute} />);
268268

269-
const input = getByRole("spinbutton");
270-
expect(input).toHaveValue(null);
269+
const input = getByRole("textbox");
270+
expect(input).toHaveValue("");
271271

272272
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
273273
await user.type(input, "42");
@@ -285,7 +285,7 @@ describe("Number Filter", () => {
285285
});
286286
});
287287

288-
expect(input).toHaveValue(100);
288+
expect(input).toHaveValue("100");
289289
expect(attribute.setValue).toHaveBeenLastCalledWith(Big(100));
290290
});
291291

packages/pluggableWidgets/datagrid-number-filter-web/src/components/__tests__/__snapshots__/DatagridNumberFilter.spec.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ exports[`Number Filter with single instance with multiple attributes renders cor
3636
</div>
3737
<input
3838
class="form-control filter-input"
39-
type="number"
39+
type="text"
4040
value=""
4141
/>
4242
</div>
@@ -89,7 +89,7 @@ exports[`Number Filter with single instance with single attribute renders correc
8989
</div>
9090
<input
9191
class="form-control filter-input"
92-
type="number"
92+
type="text"
9393
value=""
9494
/>
9595
</div>

packages/pluggableWidgets/datagrid-text-filter-web/src/DatagridTextFilter.editorPreview.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function Preview(props: DatagridTextFilterPreviewProps): ReactElement {
2929
screenReaderButtonCaption={props.screenReaderButtonCaption}
3030
screenReaderInputCaption={props.screenReaderInputCaption}
3131
styles={parseStyle(props.style)}
32-
type="text"
3332
/>
3433
);
3534
}

packages/pluggableWidgets/datagrid-text-filter-web/src/components/TextFilterContainer.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export const TextFilterContainer: (props: ContainerProps) => React.ReactElement
7474
screenReaderInputCaption={props.screenReaderInputCaption?.value}
7575
styles={props.style}
7676
tabIndex={props.tabIndex}
77-
type="text"
7877
defaultValue={props.defaultValue?.value}
7978
/>
8079
);

packages/shared/widget-plugin-filtering/src/controls/input/InputWithFilters.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export function InputWithFiltersComponent<Fn extends AllFunctions>(props: InputC
3030
onChange={input1.onChange}
3131
placeholder={props.placeholder}
3232
ref={props.inputRef}
33-
type={props.type}
3433
value={input1.value}
34+
type="text"
3535
/>
3636
</div>
3737
);

packages/shared/widget-plugin-filtering/src/controls/input/typings.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export interface BaseProps {
1212
screenReaderInputCaption?: string;
1313
styles?: React.CSSProperties;
1414
tabIndex?: number;
15-
type: "text" | "number";
1615
badge?: string;
1716
}
1817

0 commit comments

Comments
 (0)