Skip to content

Conversation

@versile2
Copy link
Contributor

@versile2 versile2 commented Jan 28, 2025

Description

Resolves #10733 by allowing the Clear button to actually clear the values
Resolves #10705 by reordering the focus logic
Resolves #10718 by removing additional click handler
Resolves #10739

How Has This Been Tested?

Unit tests passing after changing Click(s) to MouseDown(s), Visual tests done with video in comments.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Jan 28, 2025
Copy link
Member

@danielchalmers danielchalmers left a comment

Choose a reason for hiding this comment

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

small api tweak to match mudmask

@danielchalmers
Copy link
Member

Are there any other controls that have a clear button that are afflicted by this?

@versile2
Copy link
Contributor Author

Are there any other controls that have a clear button that are afflicted by this?

none that I'm aware of or that has been reported

@danielchalmers
Copy link
Member

Sorry, is AutocompleteRetainFocusTest the right example or is it for the other PR? I'm seeing a message box when I try to clear the field.

Video3.mp4

@danielchalmers
Copy link
Member

@ScarletKuro Could you take a look at the property logic when you get a chance?

@versile2
Copy link
Contributor Author

Sorry, is AutocompleteRetainFocusTest the right example or is it for the other PR? I'm seeing a message box when I try to clear the field.
Video3.mp4

No just the Docs autocomplete first example is what I used here. I did go ahead and add the logic in autocompleterefocustest to prevent popup when the value is empty

@codecov
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.83%. Comparing base (c5b4b49) to head (1da91b9).
Report is 5 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #10740   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files         427      427           
  Lines       13425    13428    +3     
  Branches     2589     2591    +2     
=======================================
+ Hits        12329    12332    +3     
  Misses        523      523           
  Partials      573      573           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@danielchalmers danielchalmers left a comment

Choose a reason for hiding this comment

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

Working on my end 👍

@ScarletKuro
Copy link
Member

ScarletKuro commented Jan 29, 2025

I hope we've made sure that everything works with both mouse and touch devices for the MudSelect and MudAutocomplete, because I'm starting to get confused. In v8, we changed from onclick to onpointerdown, then from onpointerdown to onmousedown and onclick, and now from onmousedown and onclick to just onmousedown. If people still complain, let's just revert it to how it was in v7, I guess.

I'm also slightly confused by this new method:

internal async Task HandleClearButtonAsync(MouseEventArgs e)

Wasn't the Clear functionality working before without any additional methods? I thought it was just a problem with stopPropagation, like it was here #10737 and here #10353
I'm just worried this might mess up the validation.

@versile2
Copy link
Contributor Author

I hope we've made sure that everything works with both mouse and touch devices for the MudSelect and MudAutocomplete, because I'm starting to get confused. In v8, we changed from onclick to onpointerdown, then from onpointerdown to onmousedown and onclick, and now from onmousedown and onclick to just onmousedown. If people still complain, let's just revert it to how it was in v7, I guess.

I'm also slightly confused by this new method:

internal async Task HandleClearButtonAsync(MouseEventArgs e)

Wasn't the Clear functionality working before without any additional methods? I thought it was just a problem with stopPropagation, like it was here #10737 and here #10353
I'm just worried this might mess up the validation.

I don't think so tbh, the reason I added Value/Text/bound Value underneath each is because ClearAsync method doesn't actually clear. And it has commented workarounds in it so I just copied the functionality like Select does it and left that method alone. I honestly don't use autocomplete in my projects so I'm unsure if clear actually worked right. Without the added method hitting the clear button only cleared the text so you could type something else and search. It left the Value in so if you didn't type something new it just reverts because it never fires the ValueChanged event.

@danielchalmers
Copy link
Member

danielchalmers commented Jan 29, 2025

I hope we've made sure that everything works with both mouse and touch devices for the MudSelect and MudAutocomplete, because I'm starting to get confused. In v8, we changed from onclick to onpointerdown, then from onpointerdown to onmousedown and onclick, and now from onmousedown and onclick to just onmousedown. If people still complain, let's just revert it to how it was in v7, I guess.

I didn't think about touch input initially - onpointerdown triggers when you start touching the component

onmousedown was included with onclick with the assumption that the former would trigger on mouse and the latter otherwise, but firefox handles it differently than chrome. onmousedown alone works in this case because it is synthesized as part of a full tap anyway

input events get weirdly complex. this one seems to be the solution and @versile2 has done a better job of testing it than me

@ScarletKuro ScarletKuro changed the title AutoComplete Focus and Clear MudAutocomplete: Fix Focus and Clear Jan 30, 2025
@sonarqubecloud
Copy link

Copy link
Member

@ScarletKuro ScarletKuro left a comment

Choose a reason for hiding this comment

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

LGTM, I haven't tested personally so feel free to merge if ya confident

@danielchalmers danielchalmers changed the title MudAutocomplete: Fix Focus and Clear MudAutocomplete, MudSelect: Fix Focus and Clear Jan 30, 2025
@danielchalmers danielchalmers merged commit d88dbb2 into MudBlazor:dev Jan 30, 2025
6 checks passed
@versile2 versile2 deleted the fix/autocompletefocus branch February 3, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

4 participants