Skip to content

Commit

Permalink
fix(language-selector): added clear label attribute (#4914)
Browse files Browse the repository at this point in the history
### Related Ticket(s)
#4889

### Description

The component now has the role of `edit combo` to ensure the screen readers convey its purpose to the users. The clear button also lacked a label to convey functionality upon click/enter. 

### Changelog

**New**

- added clear button label property

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "package: styles": Carbon Expressive -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
IgnacioBecerra authored Jan 21, 2021
1 parent 82f5ec0 commit cce42f4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ import readme from './README.stories.mdx';
import styles from './footer.stories.scss';

export const base = ({ parameters }) => {
const { langDisplay, language, size, langList, legalLinks, links, localeList, languageSelectorLabel, selectedLanguage } =
parameters?.props?.FooterComposite ?? {};
const {
langDisplay,
language,
size,
langList,
legalLinks,
links,
localeList,
clearSelectionLabel,
languageSelectorLabel,
selectedLanguage,
} = parameters?.props?.FooterComposite ?? {};
const { useMock } = parameters?.props?.Other ?? {};

return html`
Expand All @@ -40,6 +50,7 @@ export const base = ({ parameters }) => {
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
language-selector-label="${ifNonNull(languageSelectorLabel)}"
clear-selection-label="${ifNonNull(clearSelectionLabel)}"
selected-language="${ifNonNull(selectedLanguage)}"
>
</dds-footer-composite>
Expand All @@ -54,6 +65,7 @@ export const base = ({ parameters }) => {
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
language-selector-label="${ifNonNull(languageSelectorLabel)}"
clear-selection-label="${ifNonNull(clearSelectionLabel)}"
selected-language="${ifNonNull(selectedLanguage)}"
>
</dds-footer-container>
Expand All @@ -77,6 +89,7 @@ export const defaultLanguageOnly = ({ parameters }) => {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.REGULAR,
languageSelectorLabel: 'Choose a language',
clearSelectionLabel: 'Clear language selection',
selectedLanguage: 'English',
langList: mockLangList,
};
Expand All @@ -99,6 +112,7 @@ export const shortDefaultLanguageOnly = ({ parameters }) => {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.SHORT,
languageSelectorLabel: 'Choose a language',
clearSelectionLabel: 'Clear language selection',
selectedLanguage: 'English',
langList: mockLangList,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
@property()
buttonLabel?: string;

/**
* The clear button label for language selector.
*
* @internal
*/
@property({ attribute: 'clear-selection-label' })
clearSelectionLabel?: string;

/**
* The g11n collator to use for sorting contry names.
*/
Expand Down Expand Up @@ -229,6 +237,7 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
renderLightDOM() {
const {
buttonLabel,
clearSelectionLabel,
disableLocaleButton,
langDisplay,
langList,
Expand Down Expand Up @@ -262,7 +271,11 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
>
`
: html`
<dds-language-selector-desktop trigger-content="${languageSelectorLabel}" value="${selectedLanguage}">
<dds-language-selector-desktop
trigger-content="${languageSelectorLabel}"
value="${selectedLanguage}"
clear-selection-label="${clearSelectionLabel}"
>
${langList?.map(
language => html`
<bx-combo-box-item value="${ifNonNull(language)}">${ifNonNull(language)}</bx-combo-box-item>
Expand Down

0 comments on commit cce42f4

Please sign in to comment.