Skip to content

Commit 19e0336

Browse files
authored
refactor(ui5-option): remove disabled property (#8602)
Removes the `disabled` property of the `ui5-option`, since UX and ACC standards suggest to not include any disabled items in the dropdown. BREAKING CHANGE: The `disabled` property of the `ui5-option` is removed. If you have previously used the `disabled` property: ```html <ui5-option disabled>Option</ui5-option> ``` it will no longer work for the component. Related to #8461, #7887
1 parent c3a62b7 commit 19e0336

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

packages/main/src/Option.ts

-11
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ class Option extends UI5Element implements IOption {
2929
@property({ type: Boolean })
3030
selected!: boolean;
3131

32-
/**
33-
* Defines whether the component is in disabled state.
34-
*
35-
* **Note:** A disabled component is hidden.
36-
* @default false
37-
* @public
38-
* @since 1.0.0-rc.12
39-
*/
40-
@property({ type: Boolean })
41-
disabled!: boolean;
42-
4332
/**
4433
* Defines the tooltip of the component.
4534
* @default ""

packages/main/src/Select.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ import type { SelectMenuOptionClick, SelectMenuChange } from "./SelectMenu.js";
7878
*/
7979
interface IOption extends UI5Element {
8080
selected: boolean,
81-
disabled: boolean,
8281
title: string,
8382
icon?: string | null,
8483
value: string,
@@ -484,7 +483,7 @@ class Select extends UI5Element implements IFormElement {
484483
*/
485484
set value(newValue: string) {
486485
const menu = this._getSelectMenu();
487-
const selectOptions = Array.from(menu ? menu.children : this.children).filter(option => !option.getAttribute("disabled")) as Array<IOption>;
486+
const selectOptions = Array.from(menu ? menu.children : this.children) as Array<IOption>;
488487

489488
selectOptions.forEach(option => {
490489
option.selected = !!((option.getAttribute("value") || option.textContent) === newValue);
@@ -579,7 +578,7 @@ class Select extends UI5Element implements IFormElement {
579578
_syncSelection() {
580579
let lastSelectedOptionIndex = -1,
581580
firstEnabledOptionIndex = -1;
582-
const options = this._filteredItems;
581+
const options = this.options;
583582
const syncOpts = options.map((opt, index) => {
584583
if (opt.selected) {
585584
lastSelectedOptionIndex = index;
@@ -930,7 +929,7 @@ class Select extends UI5Element implements IFormElement {
930929
if (menu) {
931930
return menu.options;
932931
}
933-
return this._filteredItems;
932+
return this.options;
934933
}
935934

936935
get hasCustomLabel() {
@@ -1053,8 +1052,8 @@ class Select extends UI5Element implements IFormElement {
10531052
"max-width": `${this.offsetWidth}px`,
10541053
},
10551054
responsivePopoverHeader: {
1056-
"display": this._filteredItems.length && this._listWidth === 0 ? "none" : "inline-block",
1057-
"width": `${this._filteredItems.length ? this._listWidth : this.offsetWidth}px`,
1055+
"display": this.options.length && this._listWidth === 0 ? "none" : "inline-block",
1056+
"width": `${this.options.length ? this._listWidth : this.offsetWidth}px`,
10581057
},
10591058
responsivePopover: {
10601059
"min-width": `${this.offsetWidth}px`,
@@ -1091,10 +1090,6 @@ class Select extends UI5Element implements IFormElement {
10911090
return isPhone();
10921091
}
10931092

1094-
get _filteredItems() {
1095-
return this.options.filter(option => !option.disabled);
1096-
}
1097-
10981093
itemSelectionAnnounce() {
10991094
let text;
11001095
const optionsCount = this.selectOptions.length;

packages/main/test/pages/Select.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ <h2> Open event counter holder</h2>
112112

113113
<h2> Close event counter holder</h2>
114114
<ui5-input id="inputResultClose"></ui5-input>
115-
115+
116116
<section>
117117
<h3>Select aria-label and aria-labelledby</h3>
118118
<span id="infoText">info text</span>
@@ -145,7 +145,7 @@ <h3>Select in Compact</h3>
145145
<section>
146146
<h2>Select with a disabled option</h2>
147147
<ui5-select id="mySelect5">
148-
<ui5-option disabled>Cozy</ui5-option>
148+
<ui5-option >Cozy</ui5-option>
149149
<ui5-option selected>Compact</ui5-option>
150150
<ui5-option>Condensed</ui5-option>
151151
</ui5-select>

packages/playground/_stories/main/Select/Option/Option.stories.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ export default {
1313
title: "Main/Select/Option",
1414
component: "Option",
1515
argTypes,
16-
16+
1717
} as Meta<Option>;
1818

1919
const Template: UI5StoryArgs<Option, StoryArgsSlots> = (args) => {
2020
return html`<ui5-select>
2121
<ui5-option
2222
additional-text="${ifDefined(args.additionalText)}"
23-
?disabled="${ifDefined(args.disabled)}"
2423
icon="${ifDefined(args.icon)}"
2524
?selected="${ifDefined(args.selected)}"
2625
value="${ifDefined(args.value)}"

0 commit comments

Comments
 (0)