Skip to content

Commit e7f7335

Browse files
committed
SHARED(Frontend): More intuitive autocomplete behaviour.
1 parent b82c28b commit e7f7335

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

frontend/packages/shared/CHANGELOG.MD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
## [Released]
1111

12+
## [1.9.29] - 2023-10-20
13+
14+
### Changed
15+
16+
- Changed behaviour of ComboBox autocomplete: spaces are trimmed from search input and matching is only performed against the start of option labels
17+
1218
## [1.9.28] - 2023-10-05
1319

1420
### Changed

frontend/packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opetushallitus/kieli-ja-kaantajatutkinnot.shared",
3-
"version": "1.9.28",
3+
"version": "1.9.29",
44
"description": "Shared Frontend Package",
55
"exports": {
66
"./components": "./src/components/index.tsx",

frontend/packages/shared/src/components/ComboBox/ComboBox.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Autocomplete,
33
AutocompleteProps,
4+
createFilterOptions,
45
FormControl,
56
FormHelperText,
67
TextField,
@@ -47,6 +48,8 @@ const isOptionEqualToValue = (
4748
}
4849
};
4950

51+
const filterOptions = createFilterOptions({ matchFrom: 'start', trim: true });
52+
5053
export const valueAsOption = (value: string) => ({
5154
value: value,
5255
label: value,
@@ -74,6 +77,7 @@ export const ComboBox = ({
7477
getOptionLabel={getOptionLabel}
7578
isOptionEqualToValue={isOptionEqualToValue}
7679
options={values}
80+
filterOptions={filterOptions}
7781
renderInput={(params) => (
7882
<TextField
7983
{...params}
@@ -119,6 +123,7 @@ export const LabeledComboBox = ({
119123
getOptionLabel={getOptionLabel}
120124
isOptionEqualToValue={isOptionEqualToValue}
121125
options={values}
126+
filterOptions={filterOptions}
122127
renderInput={(params) => (
123128
<TextField
124129
{...params}

0 commit comments

Comments
 (0)