Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHARED:AKR:OTR:VKT:YKI(Frontend): OPHOTRKEH-224 Comboboxin näppäimistökäyttö #591

Merged
merged 2 commits into from
Oct 24, 2023
Merged
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
2 changes: 1 addition & 1 deletion frontend/packages/akr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"akr:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].28"
"shared": "npm:@opetushallitus/[email protected].29"
}
}
2 changes: 1 addition & 1 deletion frontend/packages/otr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"otr:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].28"
"shared": "npm:@opetushallitus/[email protected].29"
}
}
6 changes: 6 additions & 0 deletions frontend/packages/shared/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Released]

## [1.9.29] - 2023-10-20

### Changed

- Changed behaviour of ComboBox autocomplete: spaces are trimmed from search input and matching is only performed against the start of option labels

## [1.9.28] - 2023-10-05

### Changed
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opetushallitus/kieli-ja-kaantajatutkinnot.shared",
"version": "1.9.28",
"version": "1.9.29",
"description": "Shared Frontend Package",
"exports": {
"./components": "./src/components/index.tsx",
Expand Down
18 changes: 17 additions & 1 deletion frontend/packages/shared/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
Autocomplete,
AutocompleteProps,
createFilterOptions,
FilterOptionsState,
FormControl,
FormHelperText,
TextField,
Expand All @@ -23,7 +25,11 @@ interface ComboBoxProps {

type AutoCompleteComboBox = Omit<
AutocompleteProps<AutocompleteValue, false, false, false>,
'options' | 'renderInput'
| 'options'
| 'renderInput'
| 'getOptionLabel'
| 'isOptionEqualToValue'
| 'filterOptions'
>;

const compareOptionLabels = (a: ComboBoxOption, b: ComboBoxOption) => {
Expand All @@ -47,6 +53,14 @@ const isOptionEqualToValue = (
}
};

const filterOptions: (
options: Array<AutocompleteValue>,
state: FilterOptionsState<AutocompleteValue>
) => Array<AutocompleteValue> = createFilterOptions({
matchFrom: 'start',
trim: true,
});

export const valueAsOption = (value: string) => ({
value: value,
label: value,
Expand Down Expand Up @@ -74,6 +88,7 @@ export const ComboBox = ({
getOptionLabel={getOptionLabel}
isOptionEqualToValue={isOptionEqualToValue}
options={values}
filterOptions={filterOptions}
renderInput={(params) => (
<TextField
{...params}
Expand Down Expand Up @@ -119,6 +134,7 @@ export const LabeledComboBox = ({
getOptionLabel={getOptionLabel}
isOptionEqualToValue={isOptionEqualToValue}
options={values}
filterOptions={filterOptions}
renderInput={(params) => (
<TextField
{...params}
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/vkt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
},
"dependencies": {
"reduxjs-toolkit-persist": "^7.2.1",
"shared": "npm:@opetushallitus/[email protected].28"
"shared": "npm:@opetushallitus/[email protected].29"
}
}
2 changes: 1 addition & 1 deletion frontend/packages/yki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"yki:tslint": "yarn g:tsc --pretty --noEmit"
},
"dependencies": {
"shared": "npm:@opetushallitus/[email protected].28"
"shared": "npm:@opetushallitus/[email protected].29"
},
"devDependencies": {
"multer": "^1.4.5-lts.1"
Expand Down
10 changes: 5 additions & 5 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2890,15 +2890,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.akr@workspace:packages/akr"
dependencies:
shared: "npm:@opetushallitus/[email protected].28"
shared: "npm:@opetushallitus/[email protected].29"
languageName: unknown
linkType: soft

"@opetushallitus/kieli-ja-kaantajatutkinnot.otr@workspace:packages/otr":
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.otr@workspace:packages/otr"
dependencies:
shared: "npm:@opetushallitus/[email protected].28"
shared: "npm:@opetushallitus/[email protected].29"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2990,7 +2990,7 @@ __metadata:
languageName: unknown
linkType: soft

"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared, shared@npm:@opetushallitus/[email protected].28":
"@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared, shared@npm:@opetushallitus/[email protected].29":
version: 0.0.0-use.local
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.shared@workspace:packages/shared"
languageName: unknown
Expand All @@ -3001,7 +3001,7 @@ __metadata:
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.vkt@workspace:packages/vkt"
dependencies:
reduxjs-toolkit-persist: ^7.2.1
shared: "npm:@opetushallitus/[email protected].28"
shared: "npm:@opetushallitus/[email protected].29"
languageName: unknown
linkType: soft

Expand All @@ -3010,7 +3010,7 @@ __metadata:
resolution: "@opetushallitus/kieli-ja-kaantajatutkinnot.yki@workspace:packages/yki"
dependencies:
multer: ^1.4.5-lts.1
shared: "npm:@opetushallitus/[email protected].28"
shared: "npm:@opetushallitus/[email protected].29"
languageName: unknown
linkType: soft

Expand Down