Skip to content

fix(textfield): browser autocomplete works outside of a form #5617

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

Merged

Conversation

engrbm87
Copy link
Contributor

Add name attribute to input and textarea elements created by the text-filed element.
This enables autocomplete to work int he browser even if a form is not used.
Discussed in issue #4589

Copy link

google-cla bot commented May 15, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

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

Can you revert all formatting changes? Try not to run a formatter like prettier on our files, since it may not match our internal formatting requirements.

Thanks!

@@ -604,6 +609,7 @@ export abstract class TextField extends textFieldBaseClass {
aria-invalid=${this.hasError}
aria-label=${ariaLabel}
autocomplete=${autocomplete || nothing}
name=${this.name}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add || nothing to not render the name attribute when none is provided?

name=${this.name || nothing}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments. PR updated as advised.

@asyncLiz asyncLiz changed the title Forward name attribute to input and textarea elements in TextField fix(textfield): browser autocomplete works outside of a form May 15, 2024
@engrbm87 engrbm87 force-pushed the forward-name-to-input branch from 4b59ef6 to ba5201b Compare May 16, 2024 12:37
Copy link
Collaborator

@asyncLiz asyncLiz left a comment

Choose a reason for hiding this comment

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

Awesome!

@copybara-service copybara-service bot merged commit 0502b47 into material-components:main May 16, 2024
5 checks passed
@engrbm87 engrbm87 deleted the forward-name-to-input branch May 17, 2024 04:19
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.

2 participants