Skip to content

Commit 190cebf

Browse files
committed
fix: aria label issue for dropdown selectors
1 parent 5faea5e commit 190cebf

22 files changed

+52
-13
lines changed

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/DatagridDropdownFilter.editorPreview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function Preview(props: DatagridDropdownFilterPreviewProps): ReactElement {
1010
return (
1111
<Select
1212
className={props.class}
13+
ariaLabel={props.ariaLabel}
1314
style={parseStyle(props.style)}
1415
options={[]}
1516
empty={!props.clearable}

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/__tests__/DatagridDropdownFilter.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const commonProps: DatagridDropdownFilterContainerProps = {
2424
multiSelect: false,
2525
clearable: false,
2626
emptySelectionCaption: dynamicValue("Select"),
27+
emptyOptionCaption: dynamicValue("None"),
28+
ariaLabel: dynamicValue("AriaLabel"),
2729
selectedItemsStyle: "text",
2830
selectionMethod: "checkbox"
2931
};

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/__tests__/__snapshots__/DatagridDropdownFilter.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports[`Dropdown Filter with single instance with single attribute renders corr
4747
class="widget-dropdown-filter-menu-slot"
4848
>
4949
<ul
50-
aria-labelledby="downshift-:r0:-label"
50+
aria-label="AriaLabel"
5151
class="widget-dropdown-filter-menu"
5252
id="downshift-:r0:-menu"
5353
role="listbox"

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/components/AttrFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Connector(props: DatagridDropdownFilterContainerProps & EnumFilterProps
2424
<EnumFilterContainer
2525
{...props}
2626
multiselect={props.multiSelect}
27-
ariaLabel={props.ariaLabel?.value}
27+
ariaLabel={props.ariaLabel?.value ?? ""}
2828
className={props.class}
2929
styles={props.style}
3030
emptyOptionCaption={props.emptyOptionCaption?.value ?? ""}

packages/pluggableWidgets/datagrid-dropdown-filter-web/src/components/RefFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function Connector(props: DatagridDropdownFilterContainerProps & RefFilterProps)
1010
<RefFilterContainer
1111
{...props}
1212
multiselect={props.multiSelect}
13-
ariaLabel={props.ariaLabel?.value}
13+
ariaLabel={props.ariaLabel?.value ?? ""}
1414
className={props.class}
1515
styles={props.style}
1616
emptyOptionCaption={props.emptyOptionCaption?.value ?? ""}

packages/shared/widget-plugin-dropdown-filter/src/containers/EnumFilterContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { EnumFilterStore } from "../stores/EnumFilterStore";
1818
import { FilterOptionsType, SelectedItemsStyleEnum, SelectionMethodEnum } from "../typings/widget";
1919

2020
export interface EnumFilterContainerProps {
21-
ariaLabel?: string;
21+
ariaLabel: string;
2222
className?: string;
2323
defaultValue?: string;
2424
emptyOptionCaption: string;
@@ -70,6 +70,7 @@ const SelectWidget = observer(function SelectWidget(props: EnumFilterContainerPr
7070
showCheckboxes={ctrl1.multiselect}
7171
className={props.className}
7272
style={props.styles}
73+
ariaLabel={props.ariaLabel}
7374
/>
7475
);
7576
});
@@ -85,6 +86,7 @@ const ComboboxWidget = observer(function ComboboxWidget(props: EnumFilterContain
8586
options={ctrl2.options}
8687
inputPlaceholder={ctrl2.inputPlaceholder}
8788
emptyCaption={ctrl2.emptyCaption}
89+
ariaLabel={props.ariaLabel}
8890
useComboboxProps={ctrl2.useComboboxProps}
8991
onClear={ctrl2.handleClear}
9092
onFocus={ctrl2.handleFocus}
@@ -112,6 +114,7 @@ const TagPickerWidget = observer(function TagPickerWidget(props: EnumFilterConta
112114
onBlur={ctrl3.handleBlur}
113115
inputPlaceholder={ctrl3.inputPlaceholder}
114116
emptyCaption={ctrl3.emptyCaption}
117+
ariaLabel={props.ariaLabel}
115118
empty={ctrl3.isEmpty}
116119
showCheckboxes={props.selectionMethod === "checkbox"}
117120
selectedStyle={props.selectedItemsStyle}

packages/shared/widget-plugin-dropdown-filter/src/containers/RefFilterContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { GateProvider } from "@mendix/widget-plugin-mobx-kit/GateProvider";
1919
import { DerivedPropsGate } from "@mendix/widget-plugin-mobx-kit/props-gate";
2020

2121
export interface RefFilterContainerProps {
22-
ariaLabel?: string;
22+
ariaLabel: string;
2323
className?: string;
2424
defaultValue?: string;
2525
emptyOptionCaption: string;
@@ -73,6 +73,7 @@ const SelectWidget = observer(function SelectWidget(props: RefFilterContainerPro
7373
showCheckboxes={ctrl1.multiselect}
7474
className={props.className}
7575
style={props.styles}
76+
ariaLabel={props.ariaLabel}
7677
/>
7778
);
7879
});
@@ -89,6 +90,7 @@ const ComboboxWidget = observer(function ComboboxWidget(props: RefFilterContaine
8990
options={ctrl2.options}
9091
inputPlaceholder={ctrl2.inputPlaceholder}
9192
emptyCaption={ctrl2.emptyCaption}
93+
ariaLabel={props.ariaLabel}
9294
useComboboxProps={ctrl2.useComboboxProps}
9395
onClear={ctrl2.handleClear}
9496
onFocus={ctrl2.handleFocus}
@@ -120,6 +122,7 @@ const TagPickerWidget = observer(function TagPickerWidget(props: RefFilterContai
120122
onMenuScroll={handleMenuScroll}
121123
inputPlaceholder={ctrl3.inputPlaceholder}
122124
emptyCaption={ctrl3.emptyCaption}
125+
ariaLabel={props.ariaLabel}
123126
empty={ctrl3.isEmpty}
124127
showCheckboxes={props.selectionMethod === "checkbox"}
125128
selectedStyle={props.selectedItemsStyle}

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumBaseController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface EnumBaseControllerProps {
5656
emptyOptionCaption: string;
5757
emptySelectionCaption: string;
5858
placeholder: string;
59+
ariaLabel: string;
5960
}
6061

6162
export interface CustomOption<T> {

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumComboboxController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { ComboboxControllerMixin } from "./mixins/ComboboxControllerMixin";
55
export class EnumComboboxController extends ComboboxControllerMixin(EnumBaseController) {
66
constructor({ gate }: { gate: DerivedPropsGate<EnumBaseControllerProps> }) {
77
super({ gate, multiselect: false });
8-
this.inputPlaceholder = gate.props.placeholder ?? "Search";
8+
this.inputPlaceholder = gate.props.placeholder;
9+
this.emptyCaption = gate.props.emptySelectionCaption;
10+
this.ariaLabel = gate.props.ariaLabel;
911
}
1012
}

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumSelectController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export class EnumSelectController extends SelectControllerMixin(EnumBaseControll
77
super({ gate, multiselect: gate.props.multiselect });
88
this.emptyOption.caption = gate.props.emptyOptionCaption;
99
this.emptyCaption = gate.props.emptySelectionCaption;
10+
this.ariaLabel = gate.props.ariaLabel;
1011
}
1112
}

packages/shared/widget-plugin-dropdown-filter/src/controllers/EnumTagPickerController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export class EnumTagPickerController extends TagPickerControllerMixin(EnumBaseCo
1616

1717
constructor({ gate }: { gate: DerivedPropsGate<Props> }) {
1818
super({ gate, multiselect: gate.props.multiselect });
19-
this.inputPlaceholder = gate.props.placeholder ?? "Search";
19+
this.inputPlaceholder = gate.props.placeholder;
20+
this.emptyCaption = gate.props.emptySelectionCaption;
21+
this.ariaLabel = gate.props.ariaLabel;
2022
this.filterSelectedOptions = gate.props.selectionMethod === "rowClick";
2123
this.selectedStyle = gate.props.selectedItemsStyle;
2224
this.selectionMethod = this.selectedStyle === "boxes" ? gate.props.selectionMethod : "checkbox";

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefBaseController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ export interface RefBaseControllerProps {
3131
emptyOptionCaption: string;
3232
emptySelectionCaption: string;
3333
placeholder: string;
34+
ariaLabel: string;
3435
}

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefComboboxController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class RefComboboxController extends ComboboxControllerMixin(RefBaseContro
77
super({ gate, multiselect: false });
88
this.inputPlaceholder = gate.props.placeholder;
99
this.emptyCaption = gate.props.emptySelectionCaption;
10+
this.ariaLabel = gate.props.ariaLabel;
1011
}
1112

1213
handleFocus = (event: React.FocusEvent<HTMLInputElement>): void => {

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefSelectController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class RefSelectController extends SelectControllerMixin(RefBaseController
77
super({ gate, multiselect: gate.props.multiselect });
88
this.emptyOption.caption = gate.props.emptyOptionCaption;
99
this.emptyCaption = gate.props.emptySelectionCaption;
10+
this.ariaLabel = gate.props.ariaLabel;
1011
}
1112

1213
handleFocus = (): void => {

packages/shared/widget-plugin-dropdown-filter/src/controllers/RefTagPickerController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class RefTagPickerController extends TagPickerControllerMixin(RefBaseCont
1818
super({ gate, multiselect: gate.props.multiselect });
1919
this.inputPlaceholder = gate.props.placeholder;
2020
this.emptyCaption = gate.props.emptySelectionCaption;
21+
this.ariaLabel = gate.props.ariaLabel;
2122
this.filterSelectedOptions = gate.props.selectionMethod === "rowClick";
2223
this.selectedStyle = gate.props.selectedItemsStyle;
2324
this.selectionMethod = this.selectedStyle === "boxes" ? gate.props.selectionMethod : "checkbox";

packages/shared/widget-plugin-dropdown-filter/src/controllers/mixins/ComboboxControllerMixin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function ComboboxControllerMixin<TBase extends BaseController>(Base: TBas
2727
inputValue = "";
2828
inputPlaceholder = "";
2929
emptyCaption = "";
30+
ariaLabel = "";
3031

3132
constructor(...args: any[]) {
3233
super(...args);

packages/shared/widget-plugin-dropdown-filter/src/controllers/mixins/SelectControllerMixin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const none = "[[__none__]]" as const;
2323
export function SelectControllerMixin<TBase extends BaseController>(Base: TBase) {
2424
return class SelectControllerMixin extends Base {
2525
emptyCaption = "";
26+
ariaLabel = "";
2627

2728
readonly emptyOption = {
2829
value: none,

packages/shared/widget-plugin-dropdown-filter/src/controllers/mixins/TagPickerControllerMixin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function TagPickerControllerMixin<TBase extends BaseController>(Base: TBa
2828
inputValue = "";
2929
inputPlaceholder = "";
3030
emptyCaption = "";
31+
ariaLabel = "";
3132
filterSelectedOptions = false;
3233

3334
constructor(...args: any[]) {

packages/shared/widget-plugin-dropdown-filter/src/controls/base/OptionsWrapper.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type OptionsWrapperProps = {
1919
options: OptionWithState[];
2020
highlightedIndex: number;
2121
showCheckboxes: boolean;
22+
label: string;
2223
} & (
2324
| Pick<UseComboboxPropGetters<OptionWithState>, "getMenuProps" | "getItemProps">
2425
| Pick<UseSelectPropGetters<OptionWithState>, "getMenuProps" | "getItemProps">
@@ -27,13 +28,24 @@ type OptionsWrapperProps = {
2728
const noop = (): void => {};
2829

2930
export const OptionsWrapper = forwardRef((props: OptionsWrapperProps, ref: RefObject<HTMLDivElement>): ReactElement => {
30-
const { cls, style, onMenuScroll, isOpen, highlightedIndex, showCheckboxes, getMenuProps, getItemProps } = props;
31+
const {
32+
cls,
33+
style,
34+
onMenuScroll,
35+
isOpen,
36+
highlightedIndex,
37+
showCheckboxes,
38+
getMenuProps,
39+
getItemProps,
40+
label,
41+
options
42+
} = props;
3143
return (
3244
<div className={cls.popover} hidden={!isOpen} ref={ref} style={style}>
3345
<div className={cls.menuSlot}>
34-
<ul {...getMenuProps({ className: cls.menu })} onScroll={onMenuScroll}>
46+
<ul {...getMenuProps({ className: cls.menu, "aria-label": label })} onScroll={onMenuScroll}>
3547
{isOpen &&
36-
props.options.map((item, index) => (
48+
options.map((item, index) => (
3749
<li
3850
data-selected={item.selected || undefined}
3951
data-highlighted={highlightedIndex === index || undefined}
@@ -51,7 +63,7 @@ export const OptionsWrapper = forwardRef((props: OptionsWrapperProps, ref: RefOb
5163
{showCheckboxes && (
5264
<span className={cls.checkboxSlot}>
5365
<input
54-
className={props.cls.checkbox}
66+
className={cls.checkbox}
5567
role="presentation"
5668
type="checkbox"
5769
checked={item.selected}

packages/shared/widget-plugin-dropdown-filter/src/controls/combobox/Combobox.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface ComboboxProps {
1212
options: OptionWithState[];
1313
inputPlaceholder: string;
1414
emptyCaption: string;
15+
ariaLabel: string;
1516
empty: boolean;
1617
className?: string;
1718
style?: React.CSSProperties;
@@ -43,7 +44,7 @@ export const Combobox = observer(function Combobox(props: ComboboxProps) {
4344
<input
4445
className={cls.input}
4546
{...getInputProps({
46-
"aria-label": props.inputPlaceholder || "Search",
47+
"aria-label": props.ariaLabel,
4748
ref: inputRef,
4849
onBlur: props.onBlur,
4950
onFocus: props.onFocus,
@@ -56,6 +57,7 @@ export const Combobox = observer(function Combobox(props: ComboboxProps) {
5657
</button>
5758
<OptionsWrapper
5859
cls={cls}
60+
label={props.ariaLabel}
5961
ref={refs.setFloating}
6062
style={floatingStyles}
6163
onMenuScroll={props.onMenuScroll}

packages/shared/widget-plugin-dropdown-filter/src/controls/select/Select.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface SelectProps {
2020
onClear: () => void;
2121
onFocus?: React.FocusEventHandler<HTMLDivElement>;
2222
onMenuScroll?: React.UIEventHandler<HTMLUListElement>;
23+
ariaLabel: string;
2324
}
2425

2526
const cls = classes();
@@ -54,6 +55,7 @@ export const Select = observer(function Select(props: SelectProps): React.ReactE
5455
</div>
5556
<OptionsWrapper
5657
cls={cls}
58+
label={props.ariaLabel}
5759
ref={refs.setFloating}
5860
style={floatingStyles}
5961
onMenuScroll={props.onMenuScroll}

packages/shared/widget-plugin-dropdown-filter/src/controls/tag-picker/TagPicker.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface TagPickerProps {
1616
emptyCaption: string;
1717
showCheckboxes: boolean;
1818
selectedStyle?: "boxes" | "text";
19-
ariaLabel?: string;
19+
ariaLabel: string;
2020
className?: string;
2121
style?: React.CSSProperties;
2222
useMultipleSelectionProps: () => UseMultipleSelectionProps<OptionWithState>;
@@ -119,6 +119,7 @@ export const TagPicker = observer(function TagPicker(props: TagPickerProps): Rea
119119
</button>
120120
<OptionsWrapper
121121
cls={cls}
122+
label={inputLabel}
122123
ref={refs.setFloating}
123124
style={floatingStyles}
124125
onMenuScroll={props.onMenuScroll}

0 commit comments

Comments
 (0)