Repository navigation
Conversation
commit: |
Bundle size
PerformanceNo regressions in 36 benchmarks · precise to ±11.2% (±16.4% at worst) · ran 3m 54s · details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
45b4289 to
0d43992
Compare
0d43992 to
5d2cb2e
Compare
90dd52a to
1be6262
Compare
|
I pushed a couple of commits adjusting the icons and the toggle size. |
…efault
- Test controlled `visible` + toggle click (notifies without flipping type locally)
- Test `nativeButton={false}` toggle (visibility flip + aria-disabled suppression)
- Test that wrapping a form around the input after mount still hides on reset
- Tighten the change event assertion to `MouseEvent`
- Rename the caret test to "preserves" and note it relies on focus retention
- Document the `autoComplete="current-password"` default and the `new-password` override
b399402 to
25ed658
Compare
e6a9e65 to
9dd9d67
Compare
|
Addressing #5114 (comment) Bugs
Tests
Simplifications
Docs
🤖 Comment posted by Amp |
9dd9d67 to
3b90f42
Compare
|
@claude review |
This comment has been minimized.
This comment has been minimized.
Edge and Chromium on Windows add their own reveal button to password inputs, so a field with a Toggle showed two, and every demo hid it with `::-ms-reveal` CSS that consumers had to know to copy. The Input now carries a class for it and renders the deduplicated style element that targets that class, as ScrollArea and Select do for their scrollbars. `CSPProvider`'s `nonce` and `disableStyleElements` apply. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
Input stopped rendering Field.Control, so Field.Control's tests no longer covered it, and Input's own tests were only conformance. A shared suite now checks what Field.Control, Input and PasswordField.Input all get from `useFieldControl`: the label, the focused, filled, dirty, touched and validity attributes, `onValueChange` and Field's `disabled`. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
The reset listener runs in the capture phase, before a form's `onReset` can call `preventDefault()`, so a canceled reset kept the typed value but still restored the initial visibility. The capture listener now only notes the reset, and a bubble listener on the same root, which runs after the form's handlers, restores the visibility when the reset wasn't canceled. If a handler stops the reset's propagation, the bubble listener never runs, so the reset is decided once the dispatch is over instead. A microtask can't make this decision: for a real click, microtasks run between listeners, before `onReset` does. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
3b90f42 to
2b34ca0
Compare
…mits The submit masking was only described in the source, so a consumer controlling `revealed` saw the input switch to `type="password"` during a submit with no `onRevealedChange` call and nothing in the docs to explain it. The Input's description now says so. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
The Input's and Toggle's comments said their `type` couldn't be overridden, but a render element's props win over the component's, as they do for every Base UI part. That's intended, so the comments now say only a spread `type` is overridden. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
The description said masking keeps the password from being submitted as plain text, but the form data is the same whatever the input's `type` is. Masking keeps browsers from saving the password to autofill history and lets password managers recognize it, so the description now says that. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21cb9-530d-7520-b239-4780d6906d4e
|
Addressing #5114 (comment) Bugs
Tests
Docs
🤖 Comment posted by Amp |
This comment has been minimized.
This comment has been minimized.
the type change approach keeps coming up in reviews. i'm gonna ask agent to step back and find a simpler approach, and make sure it's testing real autofill etc.
The guide for `disableStyleElements` only covered ScrollArea and Select, so following it left Edge's native password reveal button visible next to PasswordField's Toggle. It now lists `<PasswordField.Input>` and gives the rule that hides the button. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21e9c-5c30-766a-b5d2-8df31fe830cb
|
Addressing #5114 (comment) This also replaces how the Input handles submit, so the earlier comments about submit masking are struck through and point here. Bugs
Tests
Simplifications
Docs
How a revealed password is kept out of autofill history I tested in real Chrome 159, Edge 158, Firefox 161 and Safari 26.4 profiles, typing while revealed and checking the browsers' stored autofill data and save prompts. Switching the input to
The approach:
Since the form data doesn't depend on the input's type when the form is read, hiding on submit is only tidy-up ( A field that starts revealed isn't filled with a saved password. I'm treating that as intended, so a saved password doesn't appear on screen without the user asking for it. The forms experiment ( 🤖 Comment posted by Amp |
8a850d1 to
d5c0cd4
Compare
|
Decision: how the form-submit and form-reset visibility changes are canceled ( Submitting the owning form hides the password (
<PasswordField.Root
onRevealedChange={(revealed, eventDetails) => {
if (eventDetails.reason === 'form-reset') {
eventDetails.cancel();
}
}}
>This goes back to what this reply said about michaldudak's Bug 5, and reverses the later fixes that made a native cancel also keep the visibility (Bug 1 here, and Bug 1 in round 4). Here's why:
The Root's The earlier comments that described the deferred approach are struck through and point here. 🤖 Comment posted by Amp |
d5c0cd4 to
10ccd72
Compare
Masking the input on `submit` didn't keep a revealed password out of autofill history. Safari reads the form before `submit` fires, and `form.submit()` fires no `submit` event at all, so on those paths the password was saved as plain text to autofill history, and no browser offered to save it to its password manager. While revealed, the Input now renders `autocomplete="off"`, which keeps the value out of autofill history in Chrome, Edge, Firefox and Safari on every submission path. The Input also renders `type="password"` on the server and on its first render, and switches to the visibility once it has mounted. WebKit, Blink and Gecko all remember that a field has been a password field and keep treating it as one after its type changes, so they still offer to save a password typed while it's revealed, even with `autocomplete` off. A field that has only ever been text gets no save offer. Mounting as a password keeps those behaviours for a field that starts revealed: - WebKit sets `m_hasEverBeenPasswordField` once an input has been a password field: https://github.com/WebKit/WebKit/blob/main/Source/WebCore/html/HTMLInputElement.cpp - Blink's `FormControlTypeForAutofill()` reports a text field that `HasBeenPasswordField()` as a password field: https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/html/forms/html_form_control_element.cc - Firefox's password manager finds password fields by `hasBeenTypePassword`: https://searchfox.org/firefox-main/source/toolkit/components/passwordmgr/LoginManagerChild.sys.mjs Since the form data doesn't depend on the input's type, hiding on submit is only tidy-up. Every submit attempt hides the password through `onRevealedChange` with a cancelable `'form-submit'` reason, including one a handler prevents, since most React forms submit with `preventDefault()`. Submits and resets are handled synchronously, in the order they fire. They are Base UI behaviour, so they're canceled the documented way, with `eventDetails.cancel()` for the `'form-submit'` or `'form-reset'` reason. `preventDefault()` on the form's event only cancels what the browser does, such as resetting the values, as it does elsewhere in the library. Waiting for `defaultPrevented` to be final needed a deferred task, which fired the changes after the consumer's handlers and out of order with them. `form.reset()` followed by `form.requestSubmit()` reports both changes and ends hidden: the last accepted change is kept until the script finishes, so the submit isn't compared with the stale rendered value. A usage guideline on the page says so, and links the handbook's section on canceling a Base UI event. Also from the review: - The listeners are added from a callback ref, so a render element that mounts its `<input>` later is covered. - The refs are merged once, in `useRenderElement`. - The reveal-button test checks the `display:none` declaration. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21e9c-5c30-766a-b5d2-8df31fe830cb
Exercises the field in a form: hiding on submit through each submission path, restoring on reset, canceling either change, and reading the form data while typing. A log shows each `onRevealedChange` call and what the browser sees when it builds the form data, and a separate text field with the same name checks whether a password reached autofill history. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21e9c-5c30-766a-b5d2-8df31fe830cb
Safari treats a form posting to `about:blank` as insecure, so in frame mode it asked for a username instead of reading it from the form. Every target now posts back to the page, and the frame is hidden, since it showed a white box in dark mode. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a21e9c-5c30-766a-b5d2-8df31fe830cb
10ccd72 to
3698bc7
Compare
Adds a new
PasswordFieldcomponent (in preview) — a headless password input with a button to reveal or hide the value.Preview: https://deploy-preview-5114--base-ui.netlify.app/react/components/password-field