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

MudFileUpload File Drop Zone (ActivatorContent) Issue with MudBlazor 7.x.x #9596

Open
4 tasks done
VinShen opened this issue Aug 9, 2024 · 12 comments
Open
4 tasks done
Assignees

Comments

@VinShen
Copy link

VinShen commented Aug 9, 2024

Things to check

  • I have searched the existing issues for this bug
  • To rule out a caching problem I made sure the bug also happens in an incognito tab

Bug type

Component

Component name

MudFileUpload

What happened?

In MudBlazor 7.x.x

I am putting MudTable in ActivatorContent of MudFileUpload component for Drag & Drop of files. MudTable is Drop zone.
I have MudTableSortLabel in HeaderContent of MudTable and MudTablePager in PagerContent of MudTable.

The File Picker (File Open Dialog) opens when I click in free area of MudTable. - This is Right.
The Drag and Drop of Files works in free area of MudTable. - This is Right.
The File Picker opens when I click on Header the sorting - This is WRONG
The File Picker opens when I click in MudTablePager Page Selection - This is WRONG

Expected behavior

In MudBlazor 6.x.x

I am putting MudTable in ButtonTemplate of MudFileUpload component for Drag & Drop of files. MudTable is Drop zone.
I have MudTableSortLabel in HeaderContent of MudTable and MudTablePager in PagerContent of MudTable.

The File Picker opens when I click in free area of MudTable. - This is Right.
The Drag and Drop of Files works in free area of MudTable. - This is Right.
The File Picker does not open when I click on Header the sorting - This is RIGHT
The File Picker does not open when I click in MudTablePager Page Selection - This is RIGHT

Reproduction link

https://try.mudblazor.com/snippet/camIYsYZyadwIvum

Reproduction steps

  1. Put MudTable inside ActivatorContent of MudFileUpload with InputClass, InputStyle, etc. set for Drag and Drop
  2. Add MudTablePager in PagerContent of MudTable
  3. Run in Chrome Browser
  4. Click on Rows per page: of MudTablePager OR Click on Header of MudTable
  5. The File Picker (File Open Dialog) opens in MudBlazor 7.x.x - This is WRONG
  6. This was not happening in MudBlazor 6.x.x with the same code - The MudTablePager and MudTable Header click for sort used to work without opening file picker.

Test with MudFileUpload - Hidden="@true" also.

Is it possible that the Drag and Drop will work, but the File Picker will not open on clicking ActivatorContent of MudFileUpload?
Can we add a flag to disable File Picker on click?
Please suggest solution.
Thanks

Relevant log output

No response

Version (bug)

7.0.0 ~ 7.6.0

Version (working)

6.21.0

What browsers are you seeing the problem on?

Chrome

On which operating systems are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct
Copy link

github-actions bot commented Aug 9, 2024

Thanks for wanting to do a PR, @VinShen !

We try to merge all non-breaking bugfixes and will deliberate the value of new features for the community. Please note there is no guarantee your pull request will be merged, so if you want to be sure before investing the work, feel free to contact the team first.

@ScarletKuro
Copy link
Member

@igotinfected

Personally, this doesn't seem like a bug to me but rather the correct and expected behavior. The fact that it worked the way YOU expected in v6 was likely just a lucky coincidence. Since the entire thing is inside the ActivatorContent, I would expect the entire component to open the picker when you click anywhere within its area, pixel by pixel. It shouldn't know or care about the filter header or anything else.

@igotinfected
Copy link
Member

Yeah with v7 the file upload component was rewritten for multiple reasons like accessibility, HTML semantics, complexity, usability etc., this was just a side effect of the previous implementation where the ButtonTemplate acted more as a wrapper + button template.

I don't see any way to replicate the same behaviour other than potentially rendering the fileupload manually over just_ the rows, though with this approach (and the one you have right now) you're already losing out on row click features, are you not?

@VinShen
Copy link
Author

VinShen commented Aug 12, 2024

@igotinfected
@ScarletKuro

Thanks for you reply.

I am developing a advanced Web File Manager with MudBlazor using MudTreeView, MudTable, MudFileUpload etc.

In MudBlazor 6.x.x using
MudTable as File Explorer to show Folders and Files. Also using Drag and Drop files to add files.
Entire MudTable inside MudFileUpload
There is separate button (outside this MudFileUpload+MudTable) for uploading File which uses other MudFileUpload component.
Drag and Drop on MudTable works properly.
Achieveing row ('Name') click feature using MudElement inside MudTd 'Name' - File Picker is not opened when clicked on MudElement.
Click on MudTableSortLabel in HeaderContent, MudTablePager everything works without opening the File Picker.
I may be lucky to achieve everything required in MudBlazor 6.x.x.
Attached images of MudBlazor 6.x.x.
File1
File2

In MudBlazor 7.x.x
I could achieve everything above, except click on MudTableSortLabel in HeaderContent, MudTablePager where File Picker gets opened.
Though not entire row, but I could achieve row ('Name' column) click feature using MudElement inside MudTd.
Attached images of MudBlazor 7.x.x.
File3

I ported complete Application from MudBlazor 6.x.x to 7.x.x, but can't switch to, because of this File Picker opening.
So I am stuck up.

I wish that the Drag and Drop should work without opening the File Picker on click on MudFileUpload component.
Can I disable opening of File Picker on MudFileUpload when used for Drag and Drop using InputClass or any flag?

Is there any way I can achieve this from .razor or programmetically using MudBlazor 7.x.x.?

Please suggest.

Thanks

@igotinfected
Copy link
Member

@VinShen I copied your code from the original snippet and ran it locally using 6.21.0 (replaced ActivatorContent with ButtonTemplate and removed z-10 class from MudFileUpload).

The areas surrounded by red do not activate the file picker:

image

By adding a div with stopPropagation and preventDefault around your table you can achieve the same effect (try.mudblazor.com snippet):

<div @onclick:stopPropagation
     @onclick:preventDefault>
     ...
</div>

Could you try that and let me know?

@VinShen
Copy link
Author

VinShen commented Aug 13, 2024

@igotinfected

Excellent solution.

Everything works as expected (no File Picker) except a small issue in MudTablePager First, Previous, Next, Last buttons, where File Picker opens on click. Please check in snippet sent by you.

File4

May be in future, it will be better, to provide a flag to disable opening of File Picker (when clicked on drop zone) in MudFileUpload when used specifically for Drag and Drop. In Drag Drop mode opening of File Picker every time on click is irritating.

Thanks a lot for your help.

@igotinfected
Copy link
Member

@VinShen hmm weird, I'll check when I get home in a few hours.

I think the "file drop zone only" logic can be useful in scenarios such as yours. I might look into a decent way to implement it provided the team thinks it should be part of the core component.

@igotinfected
Copy link
Member

@VinShen a bit of special case with the new way MudFileUpload works, will be "fixed" with #9626 for the time being but the solution I've provided may not be supported in the future. Will still look into a drop zone only component over the next days :)

@VinShen
Copy link
Author

VinShen commented Aug 21, 2024

@igotinfected

Any updates regarding "file drop zone only" implementation discussion with Team and #9626 fix?

@igotinfected
Copy link
Member

@VinShen been busy with the fulltime job but I'll try to put some time aside over the weekend for it!

@VinShen
Copy link
Author

VinShen commented Sep 4, 2024

@igotinfected

Tried Version v7.7.0 - No changes in MudFileUpload. I am still using Version 6.21.0

Any updates regarding "file drop zone only" implementation discussion with Team and #9626 fix?

@CoreyHayward
Copy link

@VinShen
I had this same problem and managed to fix it by wrapping the button (table in your case) in the following to essentially disable the file picker activation that gets applied to the nested buttons:

<CascadingValue Value="@((IActivatable)null!)">
  <MudTable>
    ...
  </MudTable>
</CascadingValue>

Unfortunately the @onclick:stopPropagation @onclick:preventDefault solution didn't seem to work on the latest MudBlazor version.

Obviously as @ScarletKuro mentions this is now not the intended way to use this now but in our case it has worked and will allow us to upgrade to v7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants