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

useActiveElement and useFocusWithin are not working #3760

Closed
7 tasks done
dylanalizon opened this issue Feb 1, 2024 · 6 comments
Closed
7 tasks done

useActiveElement and useFocusWithin are not working #3760

dylanalizon opened this issue Feb 1, 2024 · 6 comments

Comments

@dylanalizon
Copy link

Describe the bug

The two composables don't work properly.

useActiveElement is not reactive, so useFocusWithin doesn't work either (it uses useActiveElement).

The examples in the documentation reproduce the problems.

Workaround:

  • An empty watcher on useActiveElement fix the problem

Reproduction

https://vueuse.org/core/useActiveElement/

System Info

System:
    OS: macOS 13.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 328.92 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.15.1 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.139
    Safari: 16.1
  npmPackages:
    @vueuse/core: ^10.7.2 => 10.7.2 
    vue: ^3.2.47 => 3.4.15

Used Package Manager

yarn

Validations

@huiliangShen
Copy link
Contributor

it's because of vue/core bug 10114 and vueuse docs dependent vue@3.4.13, so it's not working only vueuse documentation!
you can update vue@lasted version if you want to these hooks normally working on your project.

@gkubisa
Copy link

gkubisa commented Feb 5, 2024

@dylanalizon While reactivity of useActiveElement works initially with vue@3.4.15, it can be easily lost. Here's how I can still reproduce it every time:

  1. Copy the example from https://vueuse.org/core/useActiveElement/ into a project using vue@3.4.15.
  2. Focus the example inputs - works.
  3. Focus the browser address bar.
  4. Focus the example inputs again - does NOT work.

Could you reopen this task, please?

cc @huiliangShen

@gkubisa
Copy link

gkubisa commented Feb 6, 2024

I reported it again in #3774 because the problem persists with the latest version of vue and vueuse.

@dylanalizon
Copy link
Author

There is a reactivity problem on vue@3.4.15, it's working with vue@3.4.14. It's already reported on Vue core repository

@huiliangShen
Copy link
Contributor

huiliangShen commented Feb 6, 2024

@dylanalizon While reactivity of useActiveElement works initially with vue@3.4.15, it can be easily lost. Here's how I can still reproduce it every time:

  1. Copy the example from https://vueuse.org/core/useActiveElement/ into a project using vue@3.4.15.
  2. Focus the example inputs - works.
  3. Focus the browser address bar.
  4. Focus the example inputs again - does NOT work.

Could you reopen this task, please?

cc @huiliangShen

@gkubisa I can't reopen this issue, sorry... You can try to use @dylanalizon said, replace vue@3.4.15 to vue@3.4.14 to test again.

@mrleblanc101
Copy link

Still does not work in the latest 3.4.27, reverting to 3.4.14 indeed fixed the issue

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

No branches or pull requests

4 participants