Skip to content

Commit 8412f62

Browse files
committed
fix(core): select multiple pointer event
Signed-off-by: Cory Rylan <crylan@nvidia.com>
1 parent ef8dc26 commit 8412f62

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎projects/core/src/combobox/combobox.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@ describe(Combobox.metadata.tag, () => {
132132
expect(dropdown.matches(':popover-open')).toBe(true);
133133
});
134134

135-
it('should assign trigger and anchor to inner input container', async () => {
135+
it('should assign anchor to inner input container', async () => {
136136
const dropdown = element.shadowRoot.querySelector<Dropdown>(Dropdown.metadata.tag);
137137
const inputContainer = element.shadowRoot.querySelector<HTMLDivElement>('[input]');
138138
expect(dropdown.anchor).toBe(inputContainer);
139-
expect(dropdown.trigger).toBe(inputContainer);
140139
});
141140

142141
it('should hide options on escape keypress', async () => {

‎projects/core/src/combobox/combobox.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class Combobox extends Control implements ContainerElement {
201201
const hasNoResults = visibleOptions.filter(o => !o.disabled).length === 0;
202202
const showCreateItem = this.#showCreateItem;
203203
return html`
204-
<nve-dropdown part="dropdown" .popoverType=${'manual'} .modal=${false} @open=${this.#onDropdownOpen} @close=${this.#closeListBox} hidden .anchor=${this.#input as HTMLElement} .trigger=${this.#input as HTMLElement} position="bottom">
204+
<nve-dropdown part="dropdown" .popoverType=${'manual'} .modal=${false} @open=${this.#openDropdown} @close=${this.#closeDropdown} hidden .anchor=${this.#input as HTMLElement} position="bottom">
205205
<nve-menu part="menu" role="listbox" style="--width: 100%; --min-width: fit-content" aria-label=${ifDefined(this.i18n.select)}>
206206
${visibleOptions.map(
207207
o => html`
@@ -371,8 +371,14 @@ export class Combobox extends Control implements ContainerElement {
371371
}
372372
}
373373

374-
#onDropdownOpen(e: Event) {
375-
(e.target as HTMLElement).hidden = false;
374+
#openDropdown() {
375+
this.#dropdown!.hidden = false;
376+
}
377+
378+
#closeDropdown() {
379+
this.#dropdown!.hidden = true;
380+
this._internals.states.delete('dirty');
381+
this.#validateSingleSelectValue();
376382
}
377383

378384
#setupAutoCompleteKeyEvents() {
@@ -515,12 +521,6 @@ export class Combobox extends Control implements ContainerElement {
515521
}
516522
}
517523

518-
#closeListBox() {
519-
this.#dropdown!.hidePopover();
520-
this._internals.states.delete('dirty');
521-
this.#validateSingleSelectValue();
522-
}
523-
524524
#validateSingleSelectValue() {
525525
const invalidInputValue =
526526
this.#select &&
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
2+
/* SPDX-License-Identifier: Apache-2.0 */
3+
4+
nve-select select[multiple] option {
5+
pointer-events: none !important;
6+
}

‎projects/core/src/select/select.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import {
1313
I18nController,
1414
onChildListMutation,
1515
getElementUpdate,
16-
scopedRegistry
16+
scopedRegistry,
17+
appendRootNodeStyle
1718
} from '@nvidia-elements/core/internal';
1819
import { Control } from '@nvidia-elements/core/forms';
1920
import { Icon } from '@nvidia-elements/core/icon';
2021
import { Menu, MenuItem } from '@nvidia-elements/core/menu';
2122
import { Dropdown } from '@nvidia-elements/core/dropdown';
2223
import { Tag } from '@nvidia-elements/core/tag';
2324
import styles from './select.css?inline';
25+
import globalStyles from './select.global.css?inline';
2426

2527
/**
2628
* @element nve-select
@@ -156,7 +158,7 @@ export class Select extends Control {
156158
return this.#select?.size === 0
157159
? html`
158160
<nve-icon name="caret" part="caret" direction="down" size="sm" aria-hidden="true"></nve-icon>
159-
<nve-dropdown part="dropdown" @close=${this.#closeDropdown} @open=${this.#openDropdown} hidden .anchor=${this.#input as HTMLElement} .trigger=${this.#input as HTMLElement} position="bottom">
161+
<nve-dropdown part="dropdown" @close=${this.#closeDropdown} @open=${this.#openDropdown} hidden .anchor=${this.#input as HTMLElement} position="bottom">
160162
${this.#menu}
161163
</nve-dropdown>`
162164
: this.#menu;
@@ -189,6 +191,11 @@ export class Select extends Control {
189191
});
190192
}
191193

194+
connectedCallback() {
195+
super.connectedCallback();
196+
appendRootNodeStyle(this, globalStyles);
197+
}
198+
192199
disconnectedCallback() {
193200
super.disconnectedCallback();
194201
this.#observers.forEach(observer => observer.disconnect());

0 commit comments

Comments
 (0)