Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@htoor3
Copy link
Contributor

@htoor3 htoor3 commented Jun 21, 2023

We have an issue where autofill in Safari Desktop is only partially autofilling the form. The only input that gets filled is the currently focused one.

This is happening for a couple of reasons:

  • We hide non-focused inputs that are part of the autofill form by sizing them to 0px height and width, among other styles.
  • This doesn't cause issues in most browsers. However, Safari does not respect offscreen or 0-sized inputs, and this leads to the partial form autofill issue.

The solution is to make sure we hide the inputs in the rest of the form from the users, without hiding it from Safari.

Fixes flutter/flutter#71275

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

@github-actions github-actions bot added the platform-web Code specifically for the web engine label Jun 21, 2023
@htoor3 htoor3 requested a review from mdebbar June 21, 2023 20:02
@htoor3 htoor3 marked this pull request as ready for review June 22, 2023 23:04
// We need to explicitly disable pointer events on the form in Safari Desktop,
// so that we don't have pointer event collisions if users hover over or click
// into the invisible autofill elements within the form.
_hideAutofillElements(formElement, shouldDisablePointerEvents: isSafariDesktopStrategy);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear to me why we are not passing shouldHideElement: !isSafariDesktopStrategy here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the autofill to work, we only need the actual <input> elements visible for Safari and don't have to worry about the <form>.

As for why we need to disable pointer events here on an "invisible" form, Safari has this weird behavior where the <form> element still registers as the target, even if the input child has disabled pointer events. This doesn't occur on Chrome or Firefox from my testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh nvm. I didn't notice that this is for <form> while the other one below is for <input> elements.

@htoor3 htoor3 requested a review from mdebbar June 23, 2023 19:10
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

LGTM

@htoor3 htoor3 added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 23, 2023
@auto-submit auto-submit bot merged commit eca910d into flutter:main Jun 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 23, 2023
fluttermirroringbot pushed a commit to flutter/flutter that referenced this pull request Jun 23, 2023
auto-submit bot pushed a commit that referenced this pull request Nov 13, 2023
In order to fix Safari autofill, we've had to give inactive elements non-zero size because Safari does not respect offscreen or 0-sized inputs, and this leads to broken autofill behavior (see: #43058).

As part of these changes, we needed to disable pointer events for the parent `<form>` element so that we don't have pointer event collisions if users hover over or click into the invisible autofill elements within that form.

This led to an issue where offsets weren't being calculated correctly for "active" inputs because they relied on pointer events bubbling up and being caught by the form.  The fix is to explicitly set pointer events on the active inputs, so that we can correctly discern when our pointer event target is actually the input and correctly calculate the offsets.

Fixes flutter/flutter#136006
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WEB] [Safari] Autofill does not fill both login fields

2 participants