Skip to content

Commit 3c4950d

Browse files
authored
fix: nav highlight shouldn't follow mouse pos when using nav arrows (#257)
1 parent 57f8d6a commit 3c4950d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/multiple-select-vanilla/src/MultipleSelectInstance.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class MultipleSelectInstance {
4040
protected okButtonElm?: HTMLButtonElement;
4141
protected filterParentElm?: HTMLDivElement | null;
4242
protected lastFocusedItemKey = '';
43+
protected lastMouseOverPosition = '';
4344
protected ulElm?: HTMLUListElement | null;
4445
protected parentElm!: HTMLDivElement;
4546
protected labelElm?: HTMLLabelElement | null;
@@ -1002,7 +1003,8 @@ export class MultipleSelectInstance {
10021003
'mouseover',
10031004
((e: MouseEvent & { target: HTMLDivElement | HTMLLIElement }) => {
10041005
const liElm = (e.target.closest('.ms-select-all') || e.target.closest('li')) as HTMLLIElement;
1005-
if (this.dropElm.contains(liElm) && this.scrolledByMouse) {
1006+
1007+
if (this.dropElm.contains(liElm) && this.lastMouseOverPosition !== `${e.clientX}:${e.clientY}`) {
10061008
const optionElms = this.dropElm?.querySelectorAll<HTMLLIElement>(OPTIONS_LIST_SELECTOR) || [];
10071009
const newIdx = Array.from(optionElms).findIndex(el => el.dataset.key === liElm.dataset.key);
10081010
if (this._currentHighlightIndex !== newIdx && !liElm.classList.contains('disabled')) {
@@ -1011,6 +1013,7 @@ export class MultipleSelectInstance {
10111013
this.changeCurrentOptionHighlight(liElm);
10121014
}
10131015
}
1016+
this.lastMouseOverPosition = `${e.clientX}:${e.clientY}`;
10141017
}) as EventListener,
10151018
undefined,
10161019
'hover-highlight',

0 commit comments

Comments
 (0)