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

Remove space from combobox single select #3384

Merged
merged 9 commits into from
Nov 29, 2024
6 changes: 6 additions & 0 deletions .changeset/yellow-days-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@navikt/ds-react": patch
"@navikt/ds-css": patch
---

Combobox: Single-select now shows cursor closer to selected item.
11 changes: 9 additions & 2 deletions @navikt/core/css/darkside/form/combobox.darkside.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}

.navds-combobox__selected-options {
gap: var(--__axc-combobox-wrapper-inner-padding);
gap: 0;
align-items: center;

& > li {
Expand All @@ -140,6 +140,10 @@
display: flex;
flex: 1;
}

&[data-type="multiple"] {
gap: var(--__axc-combobox-wrapper-inner-padding);
}
}

.navds-combobox__selected-options--no-bg {
Expand All @@ -161,7 +165,6 @@
border: none;
padding: 0;
margin: 0;
margin-left: var(--ax-spacing-1);
min-width: 10ch;
width: 100%;
height: var(--__axc-combobox-input-height);
Expand All @@ -171,6 +174,10 @@
outline: 0;
border: none;
}

.navds-combobox__selected-options > li:only-child > & {
margin-left: var(--ax-spacing-1);
}
}

.navds-combobox__input--hide-caret {
Expand Down
11 changes: 9 additions & 2 deletions @navikt/core/css/form/combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}

.navds-combobox__selected-options {
gap: var(--__ac-combobox-wrapper-inner-padding);
gap: 0;
align-items: center;
}

Expand All @@ -120,6 +120,14 @@
padding-left: 0.25rem;
}

.navds-combobox__selected-options[data-type="multiple"] {
gap: var(--__ac-combobox-wrapper-inner-padding);
}

.navds-combobox__selected-options > li:only-child > .navds-combobox__input {
margin-left: var(--a-spacing-1);
}

.navds-combobox__input-wrapper {
width: 100%;
}
Expand All @@ -129,7 +137,6 @@
border: none;
padding: 0;
margin: 0;
margin-left: var(--a-spacing-1);
min-width: 10ch;
width: 100%;
height: var(--__ac-combobox-input-height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const SelectedOptions: React.FC<SelectedOptionsProps> = ({
const { value } = useInputContext();
const { isMultiSelect } = useSelectedOptionsContext();
return (
<Chips className="navds-combobox__selected-options" size={size}>
<Chips
className="navds-combobox__selected-options"
size={size}
data-type={isMultiSelect ? "multiple" : "single"}
>
{value.length === 0 || (isMultiSelect && selectedOptions.length)
? selectedOptions.map((option, i) => (
<Option key={option.label + i} option={option} />
Expand Down
Loading