-
Notifications
You must be signed in to change notification settings - Fork 42
Combobox: add translations and adjust buttons #3409
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
Changes from 2 commits
7bc7e81
c0914b7
343489f
47971b6
ec74b74
8378547
2138753
a4cb7e4
0896b88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@navikt/ds-react": patch | ||
--- | ||
|
||
Combobox: Add title to buttons and hide them from screen readers |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @it-vegard Please have a look at the event changes I made here. I removed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import React, { forwardRef } from "react"; | ||
import { ChevronDownIcon, ChevronUpIcon } from "@navikt/aksel-icons"; | ||
import { useI18n } from "../../../util/i18n/i18n.context"; | ||
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext"; | ||
import { useInputContext } from "./Input.context"; | ||
|
||
|
@@ -13,8 +14,14 @@ export const ToggleListButton = forwardRef< | |
>(({ toggleListButtonLabel }, ref) => { | ||
const { isListOpen, toggleIsListOpen } = useFilteredOptionsContext(); | ||
const { focusInput } = useInputContext(); | ||
const translate = useI18n( | ||
"Combobox", | ||
toggleListButtonLabel ? { options: toggleListButtonLabel } : undefined, | ||
); | ||
|
||
return ( | ||
<button | ||
ref={ref} | ||
type="button" | ||
onPointerUp={() => { | ||
toggleIsListOpen(); | ||
|
@@ -24,11 +31,9 @@ export const ToggleListButton = forwardRef< | |
className="navds-combobox__button-toggle-list" | ||
aria-expanded={isListOpen} | ||
tabIndex={-1} | ||
ref={ref} | ||
aria-hidden | ||
title={translate("options")} | ||
> | ||
<span className="navds-sr-only"> | ||
{toggleListButtonLabel ?? "Alternativer"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Alternativer" doesn't tell me what the action does here. Would "open alternatives", "open optionlist" or something in that world make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this text, so I just removed it and deprecated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @it-vegard @KenAJoh Should we remove the prop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do it! Love removing unused props where possible ❤️ |
||
</span> | ||
{isListOpen ? ( | ||
<ChevronUpIcon aria-hidden /> | ||
) : ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,4 +97,11 @@ export default { | |
reset: "Reset zoom", | ||
}, | ||
}, | ||
Combobox: { | ||
addOption: "Add", | ||
searching: "Searching…", | ||
maxSelected: "{selected} of max {limit} are selected.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took the liberty of adding "max" to the text to make it clearer. |
||
clear: "Clear", | ||
options: "Options", | ||
}, | ||
} satisfies Translations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aria-hidden on button results in this error message in the console in Chrome:
Wondering if I should use a div instead? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this and

ToggleListButton
are both aria-hidden, can the wrapper-div
get aria-hidden to solve this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there actually a reason to hide this element? In Search we opt to not hide it, so is there an actual difference in expected UX here?