Skip to content

Conversation

@mohammad-mghn
Copy link
Contributor

No description provided.

Comment on lines +23 to +29
useEffect(() => {
if (isOpen) {
setTimeout(() => {
inputRef.current?.focus()
}, 0)
}
}, [isOpen])
Copy link
Contributor

@erfan-goodarzi erfan-goodarzi Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea but when we are dealing with DOM its better to use useLayoutEffect.

since its runs synchronously after all DOM mutations we may not need timeout. even if u are going to use timeout, consider the cleanup function.

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.

2 participants