Skip to content

Commit 35b1d00

Browse files
committed
feat(react-password-toggle-field): use get-deep-active-element to cross the shadow DOM boundary
1 parent cc280c0 commit 35b1d00

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

packages/react/password-toggle-field/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"build": "radix-build"
3636
},
3737
"dependencies": {
38+
"@radix-ui/deep-active-element": "workspace:*",
3839
"@radix-ui/primitive": "workspace:*",
3940
"@radix-ui/react-compose-refs": "workspace:*",
4041
"@radix-ui/react-context": "workspace:*",

packages/react/password-toggle-field/src/password-toggle-field.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useIsHydrated } from '@radix-ui/react-use-is-hydrated';
99
import { useEffectEvent } from '@radix-ui/react-use-effect-event';
1010
import type { Scope } from '@radix-ui/react-context';
1111
import { createContextScope } from '@radix-ui/react-context';
12+
import { getDeepActiveElement } from '@radix-ui/deep-active-element'
1213

1314
const PASSWORD_TOGGLE_FIELD_NAME = 'PasswordToggleField';
1415

@@ -334,7 +335,7 @@ const PasswordToggleFieldToggle = React.forwardRef<
334335
requestAnimationFrame(() => {
335336
// make sure the input still has focus (developer may have
336337
// programatically moved focus elsewhere)
337-
if (input.ownerDocument.activeElement === input) {
338+
if (getDeepActiveElement() === input) {
338339
input.selectionStart = selectionStart;
339340
input.selectionEnd = selectionEnd;
340341
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)