Skip to content

Autocomplete: Allow overriding autocomplete via UserAttributes#9337

Merged
ScarletKuro merged 1 commit intoMudBlazor:devfrom
danielchalmers:autocomplete-attribute-override
Jul 7, 2024
Merged

Autocomplete: Allow overriding autocomplete via UserAttributes#9337
ScarletKuro merged 1 commit intoMudBlazor:devfrom
danielchalmers:autocomplete-attribute-override

Conversation

@danielchalmers
Copy link
Member

Description

This removes the need for the new property and thus essentially reverts #9330.

How Has This Been Tested?

unit

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.

This removes the need for the new property and thus essentially reverts MudBlazor#9330.
@github-actions github-actions bot added enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library PR: needs review labels Jul 7, 2024
@danielchalmers danielchalmers requested a review from henon July 7, 2024 17:25
@codecov
Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.74%. Comparing base (28bc599) to head (7e13eaa).
Report is 324 commits behind head on dev.

Files Patch % Lines
...r/Components/Autocomplete/MudAutocomplete.razor.cs 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9337      +/-   ##
==========================================
+ Coverage   89.82%   90.74%   +0.91%     
==========================================
  Files         412      403       -9     
  Lines       11878    12664     +786     
  Branches     2364     2448      +84     
==========================================
+ Hits        10670    11492     +822     
+ Misses        681      619      -62     
- Partials      527      553      +26     

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

return userAutocomplete;
}

return $"mud-disable-{Guid.NewGuid()}";
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to cache the Guid.NewGuid() to a private field so it doesn't change on every render?

Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a special case where you really want a new ID on every render to counter Chrome's nasty autocompletion. But of course @Aaron2404 claims that this is not reliable any more.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, atleast not on chrome. But I'd say it's a good shout to keep the behaviour the same until changing the default method gets looked into properly.

Copy link
Member

@ScarletKuro ScarletKuro Jul 7, 2024

Choose a reason for hiding this comment

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

Do I understand correctly that this line basically disables the autocomplete assistant (aka type of information: first name, last name, etc.)? Why can't autocomplete="off" be used?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, atleast on chrome simply using "off" works. I'll try to test on other browsers and PR a default method which works for them. However it's kind of annoying to test, because it takes quite a while for the suggestions to get generated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't autocomplete="off" be used?

I just had a dejavue. We were already exactly at this point in Feb 22, 2021: #959 (comment)

Copy link
Contributor

@Aaron2404 Aaron2404 Jul 7, 2024

Choose a reason for hiding this comment

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

That's honestly awesome to see haha, I can imagine the dejavu. The issue back in 2021 seemed to be that "off" didn't work on chrome, which is promising as it does now. So I'm hoping that I'll find it works everywhere when I test it, could prevent a lot of headaches.

Copy link
Member

@ScarletKuro ScarletKuro Jul 7, 2024

Choose a reason for hiding this comment

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

I just had a dejavue. We were already exactly at this point in Feb 22, 2021: #959 (comment)

Hmm, I see. Though it was 2-3 years ago, so it could be worth checking again, and Aaron confirmed it works for him. Also, if it's in a form, you might need to put autocomplete="off" on the form itself. I think the problem is that Chrome tries to be smart and ignore developers and use the id and label names to enable auto-filling.
I found this discussion as well https://gist.github.com/niksumeiko/360164708c3b326bd1c8

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you hate it when dumb software tries to be smarter than its users. Anyway, no matter what the result of @Aaron2404's investigation, this PR should be merged in the meantime I think. Even if we set it to "off" I think it might be useful to allow overriding the value. So you can merge, if you agree @ScarletKuro

Copy link
Contributor

@Aaron2404 Aaron2404 Jul 7, 2024

Choose a reason for hiding this comment

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

I agree, it's definitely useful to allow overriding, regardless of if we find a better default method.

Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants