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

feat(useFileDialog): add listener for file change events #2893

Merged
merged 1 commit into from Mar 23, 2023
Merged

feat(useFileDialog): add listener for file change events #2893

merged 1 commit into from Mar 23, 2023

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Mar 22, 2023

Warning: ⚠️ Slowing down new functions

Due to the growing audience of VueUse, we received a huge amount of feature requests and pull requests. It's become harder and harder and recently a bit beyond our capacity to maintain the project. In the near future, we could like slowing down on accepting new features and prioritize the stability and quality of existing functions. New functions to VueUse may not be accpected. If you come up some new ideas, we advice you to have them in your codebase first instead of proposing to VueUse. You may iterate them a few time and see how them suite your needs and how them can be generalized. If you really believe they are useful to the community, you can create PR with your usercases, we are still happy to hear and discuss. Thank you for your understanding.

Description

Add listener for file changes.

I need to trigger some operations when files change at work, and currently I can only monitor its changes through watch, which is a bit cumbersome for me, so I added an onChange method in this PR for monitoring The changes in files hope to be adopted, thank you!

Additional context

Expect:

import { useFileDialog } from '@vueuse/core'

const { files, open, reset, onChange } = useFileDialog()

onChange((files) => {
  /** do something with files */
})

Actual:

import { watch } from 'vue'
import { useFileDialog } from '@vueuse/core'

const { files, open, reset } = useFileDialog()

watch(files,(files) => {
  /** do something with files */
})

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@antfu antfu added the direction: approved The direction of feature/change is approved by the team. May require some small changes. label Mar 23, 2023
@antfu antfu merged commit 5e697ba into vueuse:main Mar 23, 2023
4 checks passed
@Alfred-Skyblue Alfred-Skyblue deleted the feat-useFileDialog branch March 23, 2023 15:57
@melishev
Copy link
Contributor

@Alfred-Skyblue The onChange method does not work if I try to load the same file twice.

The method will work the first time, but the second time it will be silent

@Alfred-Skyblue
Copy link
Member Author

@melishev When the same file is selected, the onchange of the input will not be triggered. This is a feature of the input. You can pass reset as true to clear the value of the input every time it is opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
direction: approved The direction of feature/change is approved by the team. May require some small changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants