Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle possible null element in useFocusOutside focus callback #713

Merged
merged 1 commit into from
Feb 24, 2024

Conversation

yyx990803
Copy link
Contributor

@yyx990803 yyx990803 commented Feb 24, 2024

I'm working on another reactivity refactor here and noticed uncaught errors in radix-vue tests (despite all the tests passing): https://github.com/vuejs/ecosystem-ci/actions/runs/8029583738/job/21936045284

The root cause here is that the refactor gives computed a more correct behavior in that it will always give the latest value, even if its owner component has unmounted.

Previously, computed's effect is stopped after the owner component is unmounted, causing it to become stale and always return the last value before unmount. The refactor removed the need to "stop" a computed, and ensures that it never gets stale even when it has no subscriber.

The line in question here happens to rely on this behavior: although it checked for element.value at the top, after await nextTick() the element computed value actually becomes null because the owner component unsets the dependency template ref when it unmounts.

Copy link
Member

@zernonia zernonia left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the PR!

@zernonia zernonia merged commit 65e46c0 into unovue:main Feb 24, 2024
2 checks passed
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