Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions docs/ui/makeup-combobox/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/ui/makeup-combobox/index.min.js.map

Large diffs are not rendered by default.

53 changes: 26 additions & 27 deletions docs/ui/makeup-listbox-button/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/ui/makeup-listbox-button/index.min.js.map

Large diffs are not rendered by default.

50 changes: 24 additions & 26 deletions docs/ui/makeup-listbox/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/ui/makeup-listbox/index.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/ui/makeup-listbox-button/dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ function _onListboxKeyDown(e) {
}
}
function _onListboxClick(e) {
if (e.target.closest("[role=option]")) {
const optionEl = e.target.closest("[role=option]");
if (optionEl && optionEl.getAttribute("aria-disabled") !== "true") {
this.collapse();
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/makeup-listbox-button/dist/mjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function _onListboxKeyDown(e) {
}
}
function _onListboxClick(e) {
if (e.target.closest("[role=option]")) {
const optionEl = e.target.closest("[role=option]");
if (optionEl && optionEl.getAttribute("aria-disabled") !== "true") {
this.collapse();
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/makeup-listbox-button/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ function _onListboxKeyDown(e) {
}

function _onListboxClick(e) {
if (e.target.closest("[role=option]")) {
const optionEl = e.target.closest("[role=option]");

if (optionEl && optionEl.getAttribute("aria-disabled") !== "true") {
this.collapse();
}
}
Expand Down
24 changes: 24 additions & 0 deletions packages/ui/makeup-listbox-button/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ test.describe("given a listbox-button for manual selection", function () {
const disabledOptionEl = await contentEl.locator(".listbox-button__option[aria-disabled='true']").first();
await expect(disabledOptionEl).not.toBeFocused();
});

test("should not collapse overlay when clicking a disabled option", async function ({ page }) {
const container = page.locator("#manual-selected");
const btn = container.locator("button");
const content = container.locator(".listbox-button__listbox");
const disabledOptionEl = content.locator(".listbox-button__option[aria-disabled='true']").first();

await btn.click();
await expect(content).toBeVisible();
await disabledOptionEl.click({ force: true });
await expect(content).toBeVisible();
});
});
});

Expand Down Expand Up @@ -188,6 +200,18 @@ test.describe("given a listbox-button for automatic selection", function () {
const disabledOptionEl = await contentEl.locator(".listbox-button__option[aria-disabled='true']").first();
await expect(disabledOptionEl).not.toBeFocused();
});

test("should not collapse overlay when clicking a disabled option", async function ({ page }) {
const container = page.locator("#automatic-selected");
const btn = container.locator("button");
const content = container.locator(".listbox-button__listbox");
const disabledOptionEl = content.locator(".listbox-button__option[aria-disabled='true']").first();

await btn.click();
await expect(content).toBeVisible();
await disabledOptionEl.click({ force: true });
await expect(content).toBeVisible();
});
});
});

Expand Down
48 changes: 23 additions & 25 deletions packages/ui/makeup-listbox/dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,34 +116,32 @@ class _default {
}
select(index) {
this._unobserveMutations();
if (this.index !== index) {
const itemEl = this._activeDescendant.items[index];
if (this.index !== index && itemEl && itemEl.getAttribute("aria-disabled") !== "true") {
this.unselect(this.index);
const itemEl = this._activeDescendant.items[index];
if (itemEl && itemEl.getAttribute("aria-disabled") !== "true") {
const matchingItem = this.items[index];
let optionValue;
matchingItem.setAttribute("aria-selected", "true");
if (this._options.useAriaChecked === true) {
matchingItem.setAttribute("aria-checked", "true");
}
optionValue = matchingItem.innerText;
const matchingItem = this.items[index];
let optionValue;
matchingItem.setAttribute("aria-selected", "true");
if (this._options.useAriaChecked === true) {
matchingItem.setAttribute("aria-checked", "true");
}
optionValue = matchingItem.innerText;

// Check if value selector is present and use that to get innerText instead
// If its not present, will default to innerText of the whole item
if (this._options.valueSelector) {
const valueSelector = matchingItem.querySelector(this._options.valueSelector);
if (valueSelector) {
optionValue = valueSelector.innerText;
}
// Check if value selector is present and use that to get innerText instead
// If its not present, will default to innerText of the whole item
if (this._options.valueSelector) {
const valueSelector = matchingItem.querySelector(this._options.valueSelector);
if (valueSelector) {
optionValue = valueSelector.innerText;
}
this.el.dispatchEvent(new CustomEvent("makeup-listbox-change", {
detail: {
el: matchingItem,
optionIndex: index,
optionValue
}
}));
}
this.el.dispatchEvent(new CustomEvent("makeup-listbox-change", {
detail: {
el: matchingItem,
optionIndex: index,
optionValue
}
}));
}
this._observeMutations();
}
Expand Down Expand Up @@ -185,7 +183,7 @@ function _onFirstFocus() {
}
function _onClick(e) {
const toEl = e.target.closest("[role=option]");
if (toEl) {
if (toEl && toEl.getAttribute("aria-disabled") !== "true") {
this.select(this.items.indexOf(toEl));
}
}
Expand Down
Loading
Loading