Skip to content

Commit 359fc68

Browse files
adrianschmidt-botadrianschmidt
authored andcommitted
fix(picker): prevent clearing input when chip menu opens
When a chip inside the picker has a menu (actions), clicking the menu button would cause the picker to lose focus and clear its input field. This happened because focus moved to the menu's portal, which is outside the picker's DOM tree. The fix checks if any chip menu is currently open before deciding to clear the input field on blur. If a menu is open, we assume focus moved to the menu and don't clear. fix: #3676
1 parent b934660 commit 359fc68

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/components/picker/picker.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,35 @@ export class Picker {
547547
return;
548548
}
549549

550+
// Don't clear if a chip's menu is open - focus moved to the menu's portal
551+
if (this.hasOpenChipMenu()) {
552+
return;
553+
}
554+
550555
this.clearInputField();
551556
}
552557

558+
private hasOpenChipMenu(): boolean {
559+
if (!this.chipSet) {
560+
return false;
561+
}
562+
563+
// Query for any open menus inside the chips
564+
const chips = this.chipSet.shadowRoot?.querySelectorAll('limel-chip');
565+
if (!chips) {
566+
return false;
567+
}
568+
569+
for (const chip of chips) {
570+
const menu = chip.shadowRoot?.querySelector('limel-menu[open]');
571+
if (menu) {
572+
return true;
573+
}
574+
}
575+
576+
return false;
577+
}
578+
553579
/**
554580
* Input handler for the input field
555581
*

0 commit comments

Comments
 (0)