You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add nonce prop for CSP-compliant user-select style injection
The user-select hack injects a <style> element into the document head on
drag start. Under a strict Content Security Policy (style-src without
'unsafe-inline') the browser blocks it and logs a violation. This was
raised in #791 and the follow-up discussion (comment 4743333644), where
the only workaround offered required pre-injecting the element server-side
— awkward for client-only apps.
Add an optional nonce prop on DraggableCore (inherited by Draggable and
flowed through to addUserSelectStyles). When set, it's applied to the
injected element via setAttribute('nonce', ...). When omitted, fall back
to webpack's __webpack_nonce__ global if defined, read defensively behind
a typeof guard so non-webpack bundlers don't throw. The nonce is applied
only when the element is first created, preserving the existing
skip-if-present behavior.
Also documents enableUserSelectHack={false} as the no-prop opt-out.
Closes#791
0 commit comments