Skip to content
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

[TextField] Safari scrolls to top on password field focus with "filled" and "standard" variants #44396

Open
Austin1serb opened this issue Nov 12, 2024 · 4 comments
Assignees
Labels
browser: Safari bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!

Comments

@Austin1serb
Copy link

Austin1serb commented Nov 12, 2024

Steps to reproduce

Link to live example: (required)

Screen.Recording.2024-11-12.at.12.14.52.PM.mov

Steps to Reproduce:
1. Go to the TextField demo page on MUI’s website.
2. Scroll to any TextField with type="password" and set to the “filled” or “standard” variant.
3. Click on the password field in Safari (on iOS 17 or macOS).
4. Observe that the page briefly scrolls to the top of the viewport as Safari displays the password suggestion prompt.

Current behavior

In Safari, when focusing on a TextField with type="password" in either the “filled” or “standard” variant, the page flashes to the top as Safari’s password suggestion prompt appears. This behavior does not occur with the “outlined” variant.

Expected behavior

The page should remain stable and not scroll when the password field is focused, regardless of the variant in use.

Context

This issue affects the usability of forms with password fields in Safari by causing unexpected scrolling behavior. The issue appears to be related to Safari’s password suggestion feature, affecting both mobile and desktop Safari users.

Your environment

npx @mui/envinfo
 System:
    OS: macOS 14.6.1 / iOS 17
  Binaries:
    Node: 20.16.0
    npm: 10.8.1
  Browsers:
    Safari: 17.6 (macOS), iOS Safari (iOS 17)
  npmPackages:
    @mui/material: ^6.1.6
    react: ^18.2.0

Search keywords: TextField password scroll Safari, TextField password field Safari bug, Safari scroll to top password field, MUI TextField password variant issue

@Austin1serb Austin1serb added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 12, 2024
@siriwatknp
Copy link
Member

I am curious. Does it happen with native HTML input?

@siriwatknp siriwatknp added status: waiting for author Issue with insufficient information component: text field This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 13, 2024
@Austin1serb
Copy link
Author

I am curious. Does it happen with native HTML input?

I will try to reproduce the issue in HTML now.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 13, 2024
@Austin1serb
Copy link
Author

@siriwatknp,

The plot thickens!

Here’s what I found:

  1. Reproducing the Issue: I initially reproduced the scroll-to-top issue on MUI’s TextField demo page and in the CodeSandbox link using the MUI TextField component with the filled and standard variants in Safari. However, when I added a native HTML input inside the form in CodeSandbox, the issue was resolved—the page no longer scrolled to the top:

    <div>
      <label for="test-password">Standard Password</label>
      <input
        type="password"
        id="test-password"
        autocomplete="current-password"
      />
    </div>
  2. Testing with Native HTML Inputs: I tried using only a native HTML input element in a isolated environment, and the issue didn’t occur in Safari. This suggests that the behavior isn’t intrinsic to HTML but is specific to how Safari interacts with MUI’s TextField.

  3. Positioning Matters: Interestingly, when I moved the native HTML input outside the form, the issue returned. It seems like having the HTML input inside the form stabilizes Safari’s autofill behavior, possibly by providing a conventional structure that the password manager expects? I am not sure how safari detects these things.

This workaround might suggest that MUI’s TextField triggers a layout reflow or focus handling that Safari’s password manager doesn’t fully recognize without a native HTML anchor.

@siriwatknp
Copy link
Member

Clicking on the label causes the scroll but clicking on the input does not. 🤔

Helps are welcome.

@siriwatknp siriwatknp added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: Safari bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants