Skip to content

Fix picker interactions in popout documents - #367

Open
clean99 wants to merge 1 commit into
simonwep:masterfrom
clean99:contrib/popout-owner-document-events
Open

clean99 wants to merge 1 commit into
simonwep:masterfrom
clean99:contrib/popout-owner-document-events

Conversation

@clean99

@clean99 clean99 commented Nov 24, 2026

Copy link
Copy Markdown

When Pickr runs in the main window but its elements belong to a same-origin popout, clicking works but dragging, Escape, and outside-click dismissal use the wrong document. The existing el and container options accept elements.

Bind interactions after final DOM placement and use the owning document/window for events and positioning. Accept foreign-window elements, including custom buttons. On destruction, remove active drag and numeric-input listeners and cancel pending reposition work.

Reproduce on 1.10.3 at c2a51fc: load the built UMD bundle in a page, then run this and drag a handle in the popout:

const popout = window.open('about:blank', '', 'width=600,height=500');
popout.document.head.innerHTML = `<link rel="stylesheet" href="${new URL('dist/themes/classic.min.css', location.href)}">`;
const container = popout.document.body.appendChild(document.createElement('div'));
const el = container.appendChild(document.createElement('button'));
const pickr = Pickr.create({el, container, theme: 'classic', components: {palette: true, hue: true, opacity: true}});
pickr.on('init', () => pickr.show());

Regression: pnpm test test/owner-document.test.js. Covers main-document controls, popout dragging and keyboard input, dismissal, positioning, and cleanup. Also checked pnpm lint, pnpm test, pnpm build:lib, and pnpm build:demo.

Fixes #359.

Prepared by an automated contribution pipeline that I build and operate (https://github.com/clean99/software-factory); the tests and evidence above were produced by it.

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

Development

Successfully merging this pull request may close these issues.

Selection circles no longer draggable in (some) plugins running on Obsidian 10.14.5

1 participant