Skip to content

Commit

Permalink
[FRE-873] Fix auto focusing input field in shadow-dom (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
toddkao authored Jul 18, 2024
1 parent a86a85f commit 0eccea4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-doors-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

Fix auto selecting input fields in shadow-dom
6 changes: 5 additions & 1 deletion packages/widget/src/ui/AssetSelect/AssetSelectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ function AssetSelectContent({
}: Props) {
const inputRef = useRef<HTMLInputElement>(null);

useEffect(() => inputRef.current?.focus(), []);
useEffect(() => {
setTimeout(() => {
inputRef.current?.focus();
}, 0);
}, []);

const [searchValue, setSearchValue] = useState('');

Expand Down
6 changes: 5 additions & 1 deletion packages/widget/src/ui/ChainSelect/ChainSelectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ interface Props {
function ChainSelectContent({ chains, onChange, onClose }: Props) {
const inputRef = useRef<HTMLInputElement>(null);

useEffect(() => inputRef.current?.focus(), []);
useEffect(() => {
setTimeout(() => {
inputRef.current?.focus();
}, 0);
}, []);

const [searchValue, setSearchValue] = useState('');

Expand Down

0 comments on commit 0eccea4

Please sign in to comment.