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

✨ Combobox: Mulighet for å begrense hvor mange valg bruker kan ta #2260

Merged
merged 94 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
115e7d2
yarn lock
larseirikhansen Aug 30, 2023
dadb8de
setting up maxSelectedOptions
larseirikhansen Aug 30, 2023
7b84aef
added correct margin
larseirikhansen Sep 7, 2023
a1456ee
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Sep 7, 2023
61f06dd
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Sep 7, 2023
d83baba
Update tsconfig.build.json
larseirikhansen Sep 7, 2023
bd4212e
Make border of "max selected"-item in FilteredOptions overlap the lis…
it-vegard Sep 15, 2023
1ec63c3
Hide "add new value"-button if "max selected"-limit is reached
it-vegard Sep 15, 2023
db314b7
Make MaxSelected example a bit more interactive
it-vegard Sep 15, 2023
7e5df44
wip styling max-selected option
larseirikhansen Sep 18, 2023
7bc913e
merge branch
larseirikhansen Sep 26, 2023
92f4316
Merge remote-tracking branch 'origin/combobox-limit-choices' into com…
larseirikhansen Sep 26, 2023
0ca83f9
Merge branch 'main' into combobox-limit-choices
it-vegard Oct 11, 2023
2fc963a
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Oct 19, 2023
4e6f860
Merge branch 'main' into combobox-limit-choices
it-vegard Nov 1, 2023
ebdd227
Disable filteredOptions that are not selected when maxSelectedOptions…
it-vegard Nov 1, 2023
5ce1746
Fix scrolling/clipping content in FilteredOptions
it-vegard Nov 1, 2023
1aeb618
Remove hover-effects from non-selectable options
it-vegard Nov 7, 2023
c224376
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Nov 21, 2023
646f55e
add prop so user can customize message shown when max num of choices …
larseirikhansen Nov 21, 2023
ceb5cc7
merge origin combobox-limit-choices
larseirikhansen Nov 21, 2023
dd856a8
Operate directly on the DOM nodes when moving virtual focus, instead …
it-vegard Nov 23, 2023
362dd3e
Merge branch 'main' into combobox-limit-choices
it-vegard Nov 23, 2023
96d4060
make maxSelectedMessage static
larseirikhansen Nov 23, 2023
9b80589
Remove max-selected:hover
larseirikhansen Nov 24, 2023
ae3ac37
yarn lock update
larseirikhansen Nov 24, 2023
ac45c84
'cursor: not allowed' only hits disabled options
larseirikhansen Nov 24, 2023
25c23ea
remove li-margins, add ul-gap with negative margin on max-selected-op…
larseirikhansen Nov 24, 2023
6fd3c23
remove 'a' from initialstate maxSelectedOptions Story
larseirikhansen Nov 27, 2023
a2cadc1
Update @navikt/core/css/form/combobox.css
it-vegard Nov 27, 2023
c836b86
Update @navikt/core/css/form/combobox.css
it-vegard Nov 27, 2023
58bf4e9
Update @navikt/core/react/src/form/combobox/FilteredOptions/FilteredO…
it-vegard Nov 27, 2023
aa64a11
Update @navikt/core/react/src/form/combobox/FilteredOptions/useVirtua…
it-vegard Nov 27, 2023
7ad1c7a
Update @navikt/core/react/src/form/combobox/FilteredOptions/useVirtua…
it-vegard Nov 27, 2023
b8c540b
Update @navikt/core/react/src/form/combobox/combobox.stories.tsx
it-vegard Nov 27, 2023
f81f72b
type assertion
larseirikhansen Nov 27, 2023
88ec80d
remove tab-index on wrapper div
larseirikhansen Dec 1, 2023
cb9bcdc
Merge branch 'main' into combobox-limit-choices
it-vegard Dec 5, 2023
eeac3af
Merge remote-tracking branch 'origin/combobox-limit-choices' into com…
larseirikhansen Dec 6, 2023
434ad60
prototype for sticky non-selectable options
larseirikhansen Dec 6, 2023
1524626
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Dec 18, 2023
5e6a2f6
"yarn lock"
larseirikhansen Dec 18, 2023
902e10d
Fix feil med at focus-indikator for input-feltet ikke ble vist
it-vegard Jan 16, 2024
a6fa9e5
Forenkle og fikse "scroll til element" i FilteredOptions
it-vegard Jan 16, 2024
26e72c5
Sørg for at disabled FilteredOptions ikke vises under "max antall"-me…
it-vegard Jan 16, 2024
fdfb8c8
Focused option should not be covered by "max selected" message
it-vegard Jan 16, 2024
12ef187
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 16, 2024
7ebfab5
Merge remote-tracking branch 'origin/combobox-limit-choices' into com…
larseirikhansen Jan 17, 2024
ff2562b
yarn lock
larseirikhansen Jan 17, 2024
c2f27aa
Merge remote-tracking branch 'origin/main' into combobox-limit-choices
larseirikhansen Jan 17, 2024
387f4ff
Fix "scrollIntoView is not a function" error. Possibly needs to be ch…
it-vegard Jan 17, 2024
5157a7d
Loading indicator is no longer exposed as an option, so we have to ju…
it-vegard Jan 17, 2024
2a683c2
Aria-selected should not be placed on elements that are no longer rol…
it-vegard Jan 17, 2024
a17dada
Merge branch 'combobox-limit-choices' of https://github.com/navikt/ak…
it-vegard Jan 17, 2024
22179ff
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 17, 2024
54c3463
Combine all "max selected options"-related props in one object
it-vegard Jan 22, 2024
28707f1
Proper BEM syntax should use -- instead of __ for state-like classes,…
it-vegard Jan 22, 2024
aa13c36
Always show selected options in FilteredOptions, even if they don't m…
it-vegard Jan 22, 2024
89d95fa
Only to the getElementsAbleToReceiveFocus() call once per function, t…
it-vegard Jan 22, 2024
ab3e9d0
Pressing "End" should not only move focus to the end of the list, but…
it-vegard Jan 22, 2024
a934a7b
Legg til Aksel-eksempel
it-vegard Jan 22, 2024
821333b
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 22, 2024
8c57c5e
Merge branch 'main' into combobox-limit-choices
larseirikhansen Jan 24, 2024
6aa78bc
yarn changeset
larseirikhansen Jan 24, 2024
baae7c9
Update @navikt/core/css/form/combobox.css
it-vegard Jan 24, 2024
56253bf
change 'maxSelectedOptions' prop to 'maxSelected'
larseirikhansen Jan 24, 2024
2accb4a
Merge remote-tracking branch 'origin/combobox-limit-choices' into com…
larseirikhansen Jan 24, 2024
161c05a
Mark disabled options with aria-disabled
it-vegard Jan 24, 2024
2ad256d
Add max selected text to aria-describedby, so it is announced when th…
it-vegard Jan 24, 2024
820efca
Add role="status" to the wrapper for "no hits", "loading" and "max se…
it-vegard Jan 24, 2024
04398da
Remove aria-selected (again)
it-vegard Jan 24, 2024
eeed089
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 24, 2024
db568bc
Merge branch 'main' into combobox-limit-choices
KenAJoh Jan 25, 2024
e9d44ed
Merge remote-tracking branch 'origin/combobox-limit-choices' into com…
larseirikhansen Jan 25, 2024
54e0e9e
fix: form error not showing correctly
larseirikhansen Jan 25, 2024
08a6833
fix: rm left hover-border on add-new-option item
larseirikhansen Jan 25, 2024
49b7b50
Bare åpne listen som default, men la intern logikk styre etter første…
it-vegard Jan 25, 2024
90534f2
Sticky trenger ikke ligger på hver enkelt av disse, da parent wrapper…
it-vegard Jan 25, 2024
ffd2c2e
Combobox eksempler var ikke tilgjengelig i `yarn storybook:aksel` på …
it-vegard Jan 25, 2024
e6a52e7
Fjern ubrukt klasse som er i konflikt med navds-combobox__wrapper
it-vegard Jan 25, 2024
0f02ed3
Trengs ikke etter at max selected ble flyttet ut av listen
it-vegard Jan 25, 2024
c142591
Denne koden gjør ingenting
it-vegard Jan 25, 2024
f417377
Trenger ikke bruke :not, fordi vi tok vekk data-no-focus i en commit …
it-vegard Jan 25, 2024
b892e9a
Bruk dynamiske selectedOptions for å kunne endre de
it-vegard Jan 25, 2024
682c666
Update @navikt/core/css/form/combobox.css
it-vegard Jan 25, 2024
21b1515
Update @navikt/core/react/src/form/combobox/FilteredOptions/FilteredO…
it-vegard Jan 25, 2024
aae48a9
Update aksel.nav.no/website/pages/eksempler/combobox/with-max-selecte…
it-vegard Jan 25, 2024
9a822dd
Update @navikt/core/css/form/combobox.css
it-vegard Jan 25, 2024
82b0f24
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 25, 2024
fd68bd6
Do not render an empty ul for FilteredOptions, as it add a gap at the…
it-vegard Jan 26, 2024
1aa21d0
Do not render an empty non-selectables container, as it adds a gap at…
it-vegard Jan 26, 2024
7d50ae5
Merge branch 'main' into combobox-limit-choices
it-vegard Jan 26, 2024
71fbdcc
Non-selectables should not have navds-combobox__list-item class, as i…
it-vegard Jan 26, 2024
7da5e05
Copy-pasted in an extra class that broke styling for max selected
it-vegard Jan 26, 2024
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
6 changes: 6 additions & 0 deletions .changeset/red-crabs-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@navikt/ds-react": minor
"@navikt/ds-css": minor
---

:sparkles: Combobox: Mulighet for å begrense hvor mange valg bruker kan ta
74 changes: 55 additions & 19 deletions @navikt/core/css/form/combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
}

.navds-combobox__input {
z-index: 1;
flex: 1;
border: none;
padding: 0;
Expand Down Expand Up @@ -208,28 +207,24 @@
height: 1.25rem;
}

/* dropdown list */
/* dropdown & non selectable dropdown items */

.navds-combobox__list {
max-height: 290px;
overflow-y: auto;
position: absolute;
left: 0;
right: 0;
z-index: 9999;
z-index: var(--a-z-index-popover);
top: calc(100% + var(--a-spacing-2));
list-style: none;
margin: 0;
border: 1px solid var(--ac-combobox-list-border-color, var(--a-border-divider));
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0;
box-shadow: var(--a-shadow-small);
border-radius: var(--a-border-radius-medium);
gap: var(--a-spacing-1) 0;
larseirikhansen marked this conversation as resolved.
Show resolved Hide resolved
background-color: var(--ac-combobox-list-bg, var(--a-surface-default));
color: var(--ac-combobox-list-text, var(--a-text-default));
gap: var(--a-spacing-1) 0;
}

.navds-combobox__list--closed {
Expand All @@ -241,34 +236,70 @@
width: 1.5rem;
}

.navds-combobox__list_non-selectables {
position: sticky;
top: 0;
left: 0;
right: 0;
z-index: 1;
}

.navds-combobox__list-item,
.navds-combobox__list-item__no-options,
.navds-combobox__list-item__new-option {
.navds-combobox__list-item--loading,
.navds-combobox__list-item--no-options,
.navds-combobox__list-item--new-option,
.navds-combobox__list-item--max-selected {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: var(--a-spacing-3);
width: 100%;
background-color: var(--ac-combobox-list-item-bg, var(--a-surface-default));
scroll-margin-top: 50px;
}

.navds-form-field--small .navds-combobox__list-item,
.navds-form-field--small .navds-combobox__list-item__no-options,
.navds-form-field--small .navds-combobox__list-item__new-option {
.navds-form-field--small .navds-combobox__list-item--loading,
.navds-form-field--small .navds-combobox__list-item--no-options,
.navds-form-field--small .navds-combobox__list-item--new-option,
.navds-form-field--small .navds-combobox__list-item--max-selected {
padding: calc(var(--a-spacing-3) / 2) var(--a-spacing-2);
}

.navds-combobox__list-item--loading {
display: flex;
justify-content: center;
padding: var(--a-spacing-3);
background-color: var(--ac-combobox-list-item-loading-bg, var(--a-surface-default));
}

.navds-combobox__list-item--max-selected {
background: var(--ac-combobox-list-item-max-selected-bg, var(--a-surface-info-subtle));
border-start-start-radius: calc(var(--a-border-radius-medium) - 1px);
border-start-end-radius: calc(var(--a-border-radius-medium) - 1px);
border: 1px solid var(--ac-combobox-list-item-max-selected-border, var(--a-border-info));
margin-bottom: calc(var(--a-spacing-1) * -1);
}

.navds-combobox__list_non-selectables:hover {
cursor: default;
}

/* ul-list and selectable li-items */

.navds-combobox__list-options {
list-style: none;
margin: 0;
padding: 0;
width: 100%;
display: inherit;
flex-direction: inherit;
gap: inherit;
background-color: inherit;
align-items: flex-start;
}

.navds-combobox__list-item--focus,
.navds-combobox__list--with-hover .navds-combobox__list-item:hover {
.navds-combobox__list--with-hover
.navds-combobox__list-item:not([data-no-focus="true"], .navds-combobox__list-item--new-option):hover {
background-color: var(--ac-combobox-list-item-hover-bg, var(--a-surface-hover));
cursor: pointer;
border-left: 4px solid var(--ac-combobox-list-item-hover-border-left, var(--a-border-strong));
larseirikhansen marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -280,6 +311,11 @@
padding-left: calc(var(--a-spacing-2) - 4px);
}

.navds-combobox__list-item[data-no-focus="true"] {
cursor: not-allowed;
opacity: 0.4;
}

.navds-combobox__list-item--selected {
background-color: var(--ac-combobox-list-item-selected-bg, var(--a-surface-selected));
}
Expand All @@ -295,20 +331,20 @@
padding-left: calc(var(--a-spacing-3) - 4px);
}

.navds-combobox__list-item__new-option {
.navds-combobox__list-item--new-option {
border-bottom: 1px solid var(--a-border-divider);
background: var(--a-surface-neutral-subtle);
cursor: pointer;
justify-content: flex-start;
gap: 0.25rem;
}

.navds-combobox__list--with-hover .navds-combobox__list-item__new-option:hover {
.navds-combobox__list--with-hover .navds-combobox__list-item--new-option:hover {
border-bottom: 1px solid var(--a-border-divider);
background: var(--a-surface-neutral-subtle-hover);
}

.navds-combobox__list-item__new-option--focus {
.navds-combobox__list-item--new-option--focus {
box-shadow:
var(--a-shadow-focus) inset,
var(--a-border-action) 0 0 0 5px inset;
Expand Down
2 changes: 2 additions & 0 deletions @navikt/core/css/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@
"--ac-combobox-list-item-loading-bg": "--a-surface-default",
"--ac-combobox-list-item-hover-border-left": "--a-border-strong",
"--ac-combobox-list-item-selected-hover-border-left": "--a-border-focus",
"--ac-combobox-list-item-max-selected-bg": "--a-surface-info-subtle",
"--ac-combobox-list-item-max-selected-border": "--a-border-info",
"--ac-combobox-error-border": "--a-border-danger"
},
"select": {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/form/combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Combobox = forwardRef<
"navds-combobox__wrapper-inner navds-text-field__input",
{
"navds-combobox__wrapper-inner--virtually-unfocused":
activeDecendantId !== null,
activeDecendantId !== undefined,
},
)}
onClick={focusInput}
Expand Down
2 changes: 2 additions & 0 deletions @navikt/core/react/src/form/combobox/ComboboxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ComboboxProvider = forwardRef<HTMLInputElement, ComboboxProps>(
isMultiSelect,
onToggleSelected,
selectedOptions,
maxSelected,
options,
value,
onChange,
Expand Down Expand Up @@ -71,6 +72,7 @@ const ComboboxProvider = forwardRef<HTMLInputElement, ComboboxProps>(
allowNewValues,
isMultiSelect,
selectedOptions,
maxSelected,
onToggleSelected,
options,
}}
Expand Down
1 change: 0 additions & 1 deletion @navikt/core/react/src/form/combobox/ComboboxWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const ComboboxWrapper = ({
)}
onFocus={onFocusInsideWrapper}
onBlur={onBlurWrapper}
tabIndex={-1}
>
{children}
</div>
Expand Down
Loading
Loading