Skip to content

Support custom autocomplete for hidden fields#47798

Closed
zzak wants to merge 1 commit intorails:mainfrom
zzak:re-46405
Closed

Support custom autocomplete for hidden fields#47798
zzak wants to merge 1 commit intorails:mainfrom
zzak:re-46405

Conversation

@zzak
Copy link
Copy Markdown
Member

@zzak zzak commented Mar 28, 2023

@byroot
Copy link
Copy Markdown
Member

byroot commented Sep 23, 2023

I'm not sure this is quite enough because some other helpers will call hidden_field_tag under the hood (might be mistaken, I haven't done much frontend work in a long time).

Perhaps a better solution would be a config option on Action View? If people care more about generation valid HTML than to avoid this Firefox bug, we can turn the workaround off globally.

@byroot
Copy link
Copy Markdown
Member

byroot commented Sep 23, 2023

But before doing that it would be best to try to reproduce on the latest firefox, perhaps the bug was fixed after all?

@brendon
Copy link
Copy Markdown
Contributor

brendon commented Oct 21, 2024

This does need fixing. Perhaps you could just use reverse_merge instead so that incoming options have priority in these cases?

brendon added a commit to brendon/rails that referenced this pull request Oct 31, 2024
rails#43280 introduced an enforced `autocomplete="off"` to all hidden inputs generated by Rails to fix a [firefox bug](https://bugzilla.mozilla.org/show_bug.cgi?id=520561).

Unfortunately it's also a legitimate use-case to specify an `autocomplete` with a value such as `username` and a value on a hidden input. This hints to the browser that (in this example) the username of a password reset form is what we've provided as the value and the password manager can store it as such.

This commit only sets `autocomplete="off"` if another `autocomplete` value isn't provided.

Supersedes rails#47798 which didn't seem to be as elegant a solution and didn't have proper tests.
byroot pushed a commit to brendon/rails that referenced this pull request Nov 15, 2024
rails#43280 introduced an enforced `autocomplete="off"` to all hidden inputs generated by Rails to fix a [firefox bug](https://bugzilla.mozilla.org/show_bug.cgi?id=520561).

Unfortunately it's also a legitimate use-case to specify an `autocomplete` with a value such as `username` and a value on a hidden input. This hints to the browser that (in this example) the username of a password reset form is what we've provided as the value and the password manager can store it as such.

This commit only sets `autocomplete="off"` if another `autocomplete` value isn't provided.

Supersedes rails#47798 which didn't seem to be as elegant a solution and didn't have proper tests.
@zzak zzak closed this Nov 22, 2024
@zzak zzak deleted the re-46405 branch November 22, 2024 10:25
@byroot
Copy link
Copy Markdown
Member

byroot commented Nov 22, 2024

Not intending on merging this anymore?

For the Firefox bug, apparently it's still a thing, so we probably ought to keep this work around for now.

@zzak
Copy link
Copy Markdown
Member Author

zzak commented Nov 22, 2024

Not intending on merging this anymore?

For the Firefox bug, apparently it's still a thing, so we probably ought to keep this work around for now.

I thought it was fixed by #53512

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