Skip to content

Commit

Permalink
Maintain support for the old listbox HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Oct 2, 2022
1 parent ce3ffd3 commit ba78573
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/web/assets/cp/src/js/Listbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ Craft.Listbox = Garnish.Base.extend(
}

this.$container.data('listbox', this);
this.$options = this.$container.find('button');
// todo: drop [role=option] in Craft 5
this.$options = this.$container.find('button,[role=option]');

// is there already a selected option?
this.$selectedOption = this.$options.filter('[aria-pressed=true]');
// todo: drop [aria-selected=true] & attr normalization in Craft 5
this.$selectedOption = this.$options
.filter('[aria-pressed=true],[aria-selected=true]')
.removeAttr('aria-selected')
.attr('aria-pressed', 'true');
if (this.$selectedOption.length) {
this.selectedOptionIndex = this.$options.index(this.$selectedOption);
} else {
Expand Down

0 comments on commit ba78573

Please sign in to comment.