File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,11 +201,7 @@ class ToolbarSelect extends ToolbarItem {
201201 _syncOptions ( selectedOption : HTMLElement ) : void {
202202 const selectedOptionIndex = Number ( selectedOption ?. getAttribute ( "data-ui5-external-action-item-index" ) ) ;
203203 this . options . forEach ( ( option : ToolbarSelectOption , index : number ) => {
204- if ( index === selectedOptionIndex ) {
205- option . setAttribute ( "selected" , "" ) ;
206- } else {
207- option . removeAttribute ( "selected" ) ;
208- }
204+ option . selected = index === selectedOptionIndex ;
209205 } ) ;
210206 }
211207
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js" ;
33import slot from "@ui5/webcomponents-base/dist/decorators/slot.js" ;
44import property from "@ui5/webcomponents-base/dist/decorators/property.js" ;
5+ import type ToolbarSelect from "./ToolbarSelect.js" ;
56
67/**
78 * @class
@@ -23,7 +24,32 @@ class ToolbarSelectOption extends UI5Element {
2324 * @public
2425 */
2526 @property ( { type : Boolean } )
26- selected = false ;
27+ set selected ( value : boolean ) {
28+ if ( value ) {
29+ this . setAttribute ( "selected" , "" ) ;
30+ this . _clearSiblingsAndSync ( ) ;
31+ } else {
32+ this . removeAttribute ( "selected" ) ;
33+ }
34+ }
35+
36+ get selected ( ) : boolean {
37+ return this . hasAttribute ( "selected" ) ;
38+ }
39+
40+ _clearSiblingsAndSync ( ) : void {
41+ const parent = this . parentElement as ToolbarSelect ;
42+ if ( parent ) {
43+ parent . options ?. forEach ( option => {
44+ if ( option !== this ) {
45+ option . removeAttribute ( "selected" ) ;
46+ }
47+ } ) ;
48+ if ( parent . select ) {
49+ parent . select . value = this . textContent || "" ;
50+ }
51+ }
52+ }
2753
2854 /**
2955 * Defines the text of the component.
You can’t perform that action at this time.
0 commit comments