Skip to content

Add ownerDocument prop - #209

Open
Avi-Patel wants to merge 1 commit into
tajo:mainfrom
Avi-Patel:owner-document-prop
Open

Avi-Patel wants to merge 1 commit into
tajo:mainfrom
Avi-Patel:owner-document-prop

Conversation

@Avi-Patel

@Avi-Patel Avi-Patel commented Oct 12, 2026 •

Copy link
Copy Markdown

Closes #203.

Problem

Range attaches its mouse and touch listeners to the global document. When the slider is rendered in a different document, for example portaled into an iframe from code running in the parent window, those events never reach it. The thumb can't be dragged, and a click on the track leaves the slider stuck in the dragging state because mouseup is never seen.

Change

Adds an optional ownerDocument prop: the document the listeners are attached to. It defaults to the global document, so existing usage is unchanged.

<Range ownerDocument={iframe.contentDocument} {...rest} />

The value is read once in componentDidMount, so server rendering still never touches document, and listeners are always removed from the document they were added to.

Testing

  • Unit tests, typecheck, lint and build pass.
  • Checked in Chrome with a Range portaled into an iframe: without the prop a thumb drag is ignored; with it the value follows the mouse and onFinalChange fires on release.
  • e2e/final.change.test.ts passes unchanged. I did not run the screenshot tests locally because the snapshots are Linux-only.

Range attaches its mouse and touch listeners to the global `document`.
When the slider is rendered in another document, e.g. portaled into an
iframe, those events never reach it and the thumb cannot be dragged.

The optional `ownerDocument` prop sets the document the listeners are
attached to. It defaults to the global `document`, so existing usage is
unchanged.
@Avi-Patel
Avi-Patel force-pushed the owner-document-prop branch from 7bb5672 to 29ce81b Compare October 12, 2026 10:22
@Avi-Patel

Copy link
Copy Markdown
Author

@tajo please review.

Created this for #203

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.

Pass in document as property

1 participant