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

useGeolocation immediate option is not working #2524

Closed
khawarizmus opened this issue Dec 11, 2022 · 1 comment
Closed

useGeolocation immediate option is not working #2524

khawarizmus opened this issue Dec 11, 2022 · 1 comment

Comments

@khawarizmus
Copy link

Describe the bug

When using the useGeolocation with the immediate option set to false it doesn't respect it and trigger the composable anyways. this makes the web page immediately prompt the user for permissions which can is not always the desired behaviour.

const { coords, error, resume, pause } = useGeolocation({
      enableHighAccuracy: true,
      immediate: false
    }); // this will always trigger

The solution as pointed in this comment seems to add the following

 if (immediate)
    resume()

Reproduction

const { coords, error, resume, pause } = useGeolocation({ enableHighAccuracy: true, immediate: false });

System Info

System:
    OS: macOS 13.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 114.99 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v14.20.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v14.20.0/bin/npm
  Browsers:
    Chrome: 108.0.5359.94
    Firefox: 107.0.1
    Safari: 16.1
  npmPackages:
    @vueuse/core: ^9.4.0 => 9.5.0 
    @vueuse/nuxt: ^9.4.0 => 9.5.0


### Used Package Manager

pnpm

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vueuse/vueuse/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vueuse/vueuse/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vueuse.org/guide).
- [X] Check that there isn't [already an issue](https://github.com/vueuse/vueuse/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vueuse/vueuse/discussions).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@wheatjs
Copy link
Member

wheatjs commented Jan 9, 2023

Fixed in #2472

@wheatjs wheatjs closed this as completed Jan 9, 2023
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 a pull request may close this issue.

2 participants