Skip to content

Commit

Permalink
fix: nav highlight shouldn't follow mouse pos when using nav arrows (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Mar 21, 2024
1 parent 57f8d6a commit 3c4950d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class MultipleSelectInstance {
protected okButtonElm?: HTMLButtonElement;
protected filterParentElm?: HTMLDivElement | null;
protected lastFocusedItemKey = '';
protected lastMouseOverPosition = '';
protected ulElm?: HTMLUListElement | null;
protected parentElm!: HTMLDivElement;
protected labelElm?: HTMLLabelElement | null;
Expand Down Expand Up @@ -1002,7 +1003,8 @@ export class MultipleSelectInstance {
'mouseover',
((e: MouseEvent & { target: HTMLDivElement | HTMLLIElement }) => {
const liElm = (e.target.closest('.ms-select-all') || e.target.closest('li')) as HTMLLIElement;
if (this.dropElm.contains(liElm) && this.scrolledByMouse) {

if (this.dropElm.contains(liElm) && this.lastMouseOverPosition !== `${e.clientX}:${e.clientY}`) {
const optionElms = this.dropElm?.querySelectorAll<HTMLLIElement>(OPTIONS_LIST_SELECTOR) || [];
const newIdx = Array.from(optionElms).findIndex(el => el.dataset.key === liElm.dataset.key);
if (this._currentHighlightIndex !== newIdx && !liElm.classList.contains('disabled')) {
Expand All @@ -1011,6 +1013,7 @@ export class MultipleSelectInstance {
this.changeCurrentOptionHighlight(liElm);
}
}
this.lastMouseOverPosition = `${e.clientX}:${e.clientY}`;
}) as EventListener,
undefined,
'hover-highlight',
Expand Down

0 comments on commit 3c4950d

Please sign in to comment.