Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: close any open dropdown or related components with overlay clicks #41

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

<!-- If additional elements are needed for the demo, add them here. -->
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-menu@latest/dist/auro-menu__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-combobox@latest/dist/auro-combobox__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-hyperlink@latest/dist/auro-hyperlink__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-popover@latest/dist/auro-popover__bundled.js" type="module"></script>
Expand Down
13 changes: 11 additions & 2 deletions src/componentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// ---------------------------------------------------------------------

/* eslint-disable jsdoc/no-undefined-types, lit-a11y/click-events-have-key-events, jsdoc/require-description-complete-sentence, lit/binding-positions, lit/no-invalid-html, prefer-destructuring */
/* eslint-disable jsdoc/no-undefined-types, lit-a11y/click-events-have-key-events, jsdoc/require-description-complete-sentence, lit/binding-positions, lit/no-invalid-html, prefer-destructuring, max-lines */

import { LitElement } from "lit";
import { html } from 'lit/static-html.js';
Expand Down Expand Up @@ -197,7 +197,16 @@ export default class ComponentBase extends LitElement {
*/
handleOverlayClick() {
if (this.open && !this.modal) {
this.handleCloseButtonClick();
const dropdownComponents = [...this.querySelectorAll('auro-combobox, [auro-combobox], auro-select, [auro-select]')];
sun-mota marked this conversation as resolved.
Show resolved Hide resolved
const dropdowns = [
...this.querySelectorAll('auro-dropdown, [auro-dropdown]'),
...dropdownComponents.map((comp) => comp.dropdown),
];

const isAnyDropdownOpen = dropdowns.some((dropdown) => dropdown.isPopoverVisible);
if (!isAnyDropdownOpen) {
this.handleCloseButtonClick();
}
}
}

Expand Down
Loading