Skip to content

fix(treeselect): close on the first outside click and keep the panel open for nested overlays - #737

Open
tokainz wants to merge 1 commit into
openvi-foundation:masterfrom
tokainz:fix/treeselect-outside-click
Open

tokainz wants to merge 1 commit into
openvi-foundation:masterfrom
tokainz:fix/treeselect-outside-click

Conversation

@tokainz

@tokainz tokainz commented Nov 19, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes two problems with the outside click handling of TreeSelect.

Two outside clicks needed after a click into the panel outside the tree (#735)

onOverlayClick set selfClick = true in the bubble phase. Since the outside click listener runs in the capture phase (f6293cf), this happened after the listener had already run, so selfClick swallowed the next click instead, even when it was outside. Clicks on the tree are not affected, because the tree stops their propagation. In the capture phase the click target is still in the DOM when the listener runs, so isOutsideClicked() already handles clicks inside the panel. onOverlayClick no longer sets selfClick. It still emits overlay-click.

Nested overlays (#736)

Same fix as for DatePicker, MultiSelect, AutoComplete, Select and CascadeSelect:

  • The TreeSelect listens to overlay-click while its panel is open. If the event comes from a component inside its panel, it sets selfClick and ignores the following outside click. Select emits overlay-click on mousedown, so this also works when the Select has already closed by the time the click event arrives.
  • isNestedOverlayVisible() checks for an open overlay inside the panel. While the nested Select is open, a click outside closes only the Select. A second click closes the TreeSelect.

The listener is removed in onOverlayLeave and beforeUnmount. Like in CascadeSelect, the tree nodes are treeitems with aria-expanded, so isNestedOverlayVisible() skips them ([aria-expanded="true"]:not([role="treeitem"])).

Tests

There was no spec for TreeSelect yet. The new TreeSelect.spec.js covers the same 5 nested overlay tests as the other components, plus a test for the first outside click after a click inside the panel and one for an outside click while a node is expanded.

Verified manually in the showcase: after a click on the footer content, the first click outside closes the panel. Expanding and collapsing nodes keeps the panel open, selecting a node still closes it. Picking an option in a nested Select keeps the panel open, whether the Select was opened with the mouse or the keyboard.

Related issue

Closes #735
Closes #736

Checklist

  • Tests added or updated for the change
  • pnpm run lint and pnpm run format pass
  • Changelog entry added under ## [Unreleased] in CHANGELOG.md

@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

@tokainz is attempting to deploy a commit to the njevric's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tokainz
tokainz force-pushed the fix/treeselect-outside-click branch from d0be913 to f0b3b0e Compare November 20, 2026 21:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant