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

Make possible to pick both files and folders #10936

Merged
merged 4 commits into from
Aug 30, 2018

Conversation

danxuliu
Copy link
Member

The file picker could be used to pick either files or folders, but not both. This pull request fixes that, as well as being able to choose a folder just by hitting enter even if the default action button was disabled, and wrong handling of an empty array as the mime type filter.

This change should be backwards compatible; when the filter is undefined or null only files can be picked, which is the same as before; in order to be able to pick both files and folders ['*', 'httpd/unix-directory'] should be explicitly used.

When "enter" is pressed in the file picker a "click" event is triggered
on the primary action button. However, in some cases, like when the file
picker is in "Choose" mode and the current directory in the file picker
is the root folder, the primary action button is disabled. In those
cases pressing enter should not trigger a click action on the button and
be ignored instead.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
When the mime type is an empty array no filter should be applied.
However, the filter was loosely compared to an empty array, but as
arrays are objects then it became an implicit strict equality comparison
which always failed due to being different objects. Now the length of
the array is compared instead, and also moved outside the loop as it is
not needed to check it for each file.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
This will make easier to check if both directories and files should be
pickable.

This also removes an unused assignment to the mime type.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Tested and works 👍

@MorrisJobke MorrisJobke merged commit f393cb7 into master Aug 30, 2018
@MorrisJobke MorrisJobke deleted the make-possible-to-pick-both-files-and-folders branch August 30, 2018 19:03
@MorrisJobke MorrisJobke mentioned this pull request Aug 30, 2018
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants