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

fix: onchange and border #4652

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .changeset/thick-olives-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@ultraviolet/ui": patch
---

`<SelectInputV2 />`:
- onChange handle on checkboxes fix
- visual indication of focused item for keyboard users
- no scroll when opening the dropdown with "Enter"
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ exports[`SelectInputField > should display right value on grouped options 1`] =
margin-right: 0.25rem;
color: #3f4250;
border-radius: 0.25rem;
border: 1px transparent solid;
}

.emotion-32:hover,
.emotion-32:focus {
background-color: #f1eefc;
color: #641cb3;
cursor: pointer;
outline: none;
}

.emotion-32[aria-selected='true'] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4467,14 +4467,14 @@ exports[`Pagination > should work correctly with perPage 1`] = `
margin-right: 0.25rem;
color: #3f4250;
border-radius: 0.25rem;
border: 1px transparent solid;
}

.emotion-31:hover,
.emotion-31:focus {
background-color: #f1eefc;
color: #641cb3;
cursor: pointer;
outline: none;
}

.emotion-31[aria-selected='true'] {
Expand Down Expand Up @@ -4888,7 +4888,6 @@ exports[`Pagination > should work correctly with perPage 1`] = `
data-grouped="false"
id="select-dropdown"
role="listbox"
tabindex="-1"
>
<div
class="emotion-29 emotion-1"
Expand Down
30 changes: 27 additions & 3 deletions packages/ui/src/components/SelectInputV2/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@

color: ${({ theme }) => theme.colors.neutral.text};
border-radius: ${({ theme }) => theme.radii.default};
border: 1px transparent solid;

&:hover, :focus {
background-color: ${({ theme }) => theme.colors.primary.background};
color: ${({ theme }) => theme.colors.primary.text};
cursor: pointer;
outline: none;
}

&[aria-selected='true'] {
Expand Down Expand Up @@ -213,6 +213,11 @@
event.preventDefault()
moveFocusUp()
}

if (event.key === ' ') {
// No scroll
event.preventDefault()

Check warning on line 219 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L219

Added line #L219 was not covered by tests
}
}

const handleKeyDown = (
Expand Down Expand Up @@ -404,6 +409,7 @@
value="select-all"
data-testid="select-all-checkbox"
tabIndex={-1}
onChange={selectAllOptions}
>
<Stack direction="column">
<Text as="span" variant="body" placement="left">
Expand Down Expand Up @@ -452,8 +458,16 @@
value={group}
data-testid="select-group"
tabIndex={-1}
onChange={() =>

Check warning on line 461 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L461

Added line #L461 was not covered by tests
selectAllGroup ? handleSelectGroup(group) : null
}
>
<Text variant="caption" as="span" placement="left">
<Text
variant="caption"
as="span"
placement="left"
sentiment="neutral"
>
{group.toUpperCase()}
</Text>
</StyledCheckbox>
Expand Down Expand Up @@ -511,6 +525,11 @@
disabled={option.disabled}
value={option.value}
tabIndex={-1}
onChange={() => {

Check warning on line 528 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L528

Added line #L528 was not covered by tests
if (!option.disabled) {
handleClick(option, group)

Check warning on line 530 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L530

Added line #L530 was not covered by tests
}
}}
>
<DisplayOption
option={option}
Expand All @@ -537,7 +556,6 @@
) : (
<DropdownContainer
role="listbox"
tabIndex={-1}
id="select-dropdown"
onKeyDown={handleKeyDownSelect}
gap={0.25}
Expand All @@ -563,6 +581,7 @@
value="select-all"
data-testid="select-all-checkbox"
tabIndex={-1}
onChange={selectAllOptions}
>
<Stack direction="column">
<Text as="span" variant="body" placement="left">
Expand Down Expand Up @@ -623,6 +642,11 @@
disabled={option.disabled}
value={option.value}
tabIndex={-1}
onChange={() => {

Check warning on line 645 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L645

Added line #L645 was not covered by tests
if (!option.disabled) {
handleClick(option)

Check warning on line 647 in packages/ui/src/components/SelectInputV2/Dropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/Dropdown.tsx#L647

Added line #L647 was not covered by tests
}
}}
>
<DisplayOption
option={option}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
onChange?.(selectedData.selectedValues[0] ?? '')
}
}
} else if (key === 'Tab') {
searchInputRef.current?.blur()

Check warning on line 133 in packages/ui/src/components/SelectInputV2/SearchBarDropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/SearchBarDropdown.tsx#L133

Added line #L133 was not covered by tests
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/SelectInputV2/SelectBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@
document.getElementById(`option-0`)?.focus()
}
}
if (event.key === ' ') {
event.preventDefault()

Check warning on line 375 in packages/ui/src/components/SelectInputV2/SelectBar.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/SelectInputV2/SelectBar.tsx#L375

Added line #L375 was not covered by tests
}

return ['Enter', ' '].includes(event.key) && openable
? setIsDropdownVisible(!isDropdownVisible)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,14 @@ exports[`UnitInput > renders click 1`] = `
margin-right: 0.25rem;
color: #3f4250;
border-radius: 0.25rem;
border: 1px transparent solid;
}

.emotion-33:hover,
.emotion-33:focus {
background-color: #f1eefc;
color: #641cb3;
cursor: pointer;
outline: none;
}

.emotion-33[aria-selected='true'] {
Expand Down Expand Up @@ -1171,7 +1171,6 @@ exports[`UnitInput > renders click 1`] = `
data-grouped="false"
id="select-dropdown"
role="listbox"
tabindex="-1"
>
<div
class="emotion-31 emotion-1"
Expand Down
Loading