Skip to content

Commit

Permalink
don't display tooltip until after expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
dlockhart committed Nov 20, 2024
1 parent 8621a0f commit 153d2f3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions components/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function addSpaceListener() {
if (spaceListenerAdded) return;
spaceListenerAdded = true;
document.addEventListener('keydown', e => {
if (e.keyCode !== 32) return;
if (e.key !== ' ') return;
spacePressed = true;
});
document.addEventListener('keyup', e => {
if (e.keyCode !== 32) return;
if (e.key !== ' ') return;
spacePressed = false;
});
}
Expand Down Expand Up @@ -244,6 +244,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
onSubscribe: this._updateActiveFiltersSubscriber.bind(this),
updateSubscribers: this._updateActiveFiltersSubscribers.bind(this)
});
this._spacePressedDuringLastSelection = false;
}

static get focusElementSelector() {
Expand Down Expand Up @@ -617,7 +618,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
return html`
<d2l-list-item
id="${itemId}"
@d2l-list-item-selected="${ifDefined(item.additionalContent ? this._handleListItemSelelcted : undefined)}"
@d2l-list-item-selected="${item.additionalContent ? this._handleListItemSelected : undefined}"
?selection-disabled="${item.disabled}"
?hidden="${item.hidden}"
key="${item.key}"
Expand Down Expand Up @@ -896,18 +897,22 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
}

async _handleExpandCollapse(e) {
const eventPromise = e.target.expanded ? e.detail.expandComplete : e.detail.collapseComplete;
const expanded = e.target.expanded;
const eventPromise = expanded ? e.detail.expandComplete : e.detail.collapseComplete;
const parentListItem = e.target.closest('d2l-list-item');
parentListItem.classList.add('expanding-content');

await eventPromise;
parentListItem.classList.remove('expanding-content');

if (expanded && !hasDisplayedKeyboardTooltip && this._spacePressedDuringLastSelection) {
this._displayKeyboardTooltip = true;
hasDisplayedKeyboardTooltip = true;
}
}

_handleListItemSelelcted() {
if (hasDisplayedKeyboardTooltip || !spacePressed) return;
this._displayKeyboardTooltip = true;
hasDisplayedKeyboardTooltip = true;
_handleListItemSelected() {
this._spacePressedDuringLastSelection = spacePressed;
}

_handleSearch(e) {
Expand Down

0 comments on commit 153d2f3

Please sign in to comment.