Skip to content

fix(RangeCalendar): use getEventTarget for shadow DOM compatibility - #10449

Closed
waterWang wants to merge 1 commit into
adobe:mainfrom
waterWang:fix/range-calendar-shadow-dom-geteventtarget
Closed

fix(RangeCalendar): use getEventTarget for shadow DOM compatibility#10449
waterWang wants to merge 1 commit into
adobe:mainfrom
waterWang:fix/range-calendar-shadow-dom-geteventtarget

Conversation

@waterWang

Copy link
Copy Markdown

What changed

When RangeCalendar is rendered inside a shadow root, the window-level pointerup listener (endDragging) reads e.target directly. In shadow DOM, events are retargeted so e.target is the shadow host, not the actual calendar cell button. This causes nodeContains(ref.current, target) to always return false, and commitSelection() runs on every single click — immediately committing start === end.

Fix

Used the existing getEventTarget helper from @react-aria/src/utils/shadowdom/DOMFunctions which reads e.composedPath()[0] from the event, giving the actual target element even inside shadow DOM.

Related issue

Closes #10330

When RangeCalendar is rendered inside a shadow root, the window-level
pointerup listener (endDragging) reads e.target directly. In shadow DOM,
events are retargeted so e.target is the shadow host, not the actual
calendar cell button. This causes nodeContains to always return false,
and commitSelection() runs on every single click, immediately committing
start === end.

Fix: use the existing getEventTarget helper which reads e.composedPath()[0]
from the event, giving the actual target element even inside shadow DOM.

Closes adobe#10330
@snowystinger

Copy link
Copy Markdown
Member

Duplicate of
#9632

and also of #10350 and #10347
Please have your AI check if a PR already exists before opening a new one. Also, if you point it at our contributing guide and our github issue template, it'll know that tests are expected.

Closing

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RangeCalendar inside shadow DOM commits range on first click (endDragging uses retargeted e.target)

2 participants