Bug 172567 - Safari autofill doesn't work in form inputs that are in a shadow root
Summary: Safari autofill doesn't work in form inputs that are in a shadow root
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Ricky Mondello
URL:
Keywords: InRadar
: 257804 (view as bug list)
Depends on:
Blocks: 148695
  Show dependency treegraph
 
Reported: 2017-05-24 17:57 PDT by Taylor Savage
Modified: 2023-06-14 10:19 PDT (History)
18 users (show)

See Also:


Attachments
Code reproduction (2.49 KB, text/html)
2022-07-13 08:53 PDT, Liam DeBeasi
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Taylor Savage 2017-05-24 17:57:11 PDT
Autofill for form input fields such as credit card fields, email addresses, etc. doesn't appear to work for form inputs that are inside shadow roots.

Reproduction:

1) Go to polymer-shop2.appspot.com
2) Tap on "men's outerwear"
3) Tap on "Men's tech shell full-zip"
4) Tap on "Add to cart"
5) Tap on the cart icon on the upper right
6) Tap on "Checkout"
7) Tap in the "Email" field

Expected:
The autofill selector should appear to enable you to autofill from a contact.

Result:
No autofill appears supported.

This is also the case for other fields I'd expect to autofill, like "Card Number"
Comment 1 Radar WebKit Bug Importer 2017-05-24 21:02:28 PDT
<rdar://problem/32394943>
Comment 2 Samuel Sheldon 2021-11-10 05:58:03 PST
I have tried this in iOS 15.1 and this issue is still not fixed. 

This is a critical feature for many developers, is there any way to get an estimate on a fix? Or at the very lease a temporary work around or solution we can use in the mean time?

Any update or assistance you can give will be helpful, thanks!
Comment 3 Samuel Sheldon 2021-11-17 08:23:33 PST
Any update on this issue?
Comment 4 peter.koshelev 2022-02-22 04:10:59 PST
Same issue, when is it expected to be fixed!? 

it's 5th year already
Comment 5 Daniel Ehrhardt 2022-07-03 13:33:49 PDT
Safari is the new Internet Explorer.
Comment 6 Liam DeBeasi 2022-07-13 08:53:31 PDT
Created attachment 460859 [details]
Code reproduction

I am attaching a new code reproduction as the link in the initial post is broken. Is there anything else we can do to help get this issue resolved?

Steps to reproduce:

1. Open reproduction on an iOS device.
2. Tap into any of the inputs in the "Native" section. Observe that the autofill/passwords button appears above the keyboard.
3. Tap into any of the inputs in the "Web Component + Shadow DOM" section. Observe that the autofill/passwords button does not appear above the keyboard.
4. Tap into any of the inputs in the "Web Component + Light DOM" section. Observe that the autofill/passwords button appears above the keyboard.

Expected Behavior:

I expect that the autofill button will appear regardless of the Shadow DOM.

Actual Behavior:

The autofill button only appears on inputs in the light DOM.
Comment 7 Aidar 2022-09-14 02:54:16 PDT
Please fix this bug🙏
Comment 8 ben.hirsch 2023-01-03 07:18:58 PST
Any update on the progress of this? Autofill is supported by other browser makers. 

Looks like there is some progress in Chromium: https://chromestatus.com/feature/5769419581030400

Does webkit have any plans to support? Seems like a pretty important feature.
Comment 9 Ricky Mondello 2023-01-04 18:14:37 PST
Fixing this actually requires a Safari change, not a WebKit change. I will report back to this bug when a fix for this is testable in Safari Technology Preview.
Comment 10 Martin 2023-01-06 13:10:45 PST
Would love to see support for this.

We've had great feedback from clients moving away from remotely hosted iframes and re-implementing in client-hosted Shadow DOMs, but cannot recommend Safari on Mac over Chrome as a result of lacking autofill support.

On iOS, Safari performs better than the Chrome WebKit wrapper. Unlike Chrome, Safari can tab input fields and toggle the virtual keyboard. Unfortunately neither browser does autofill.
Comment 11 Ryosuke Niwa 2023-01-06 13:13:20 PST
It would be really helpful for people commenting here to post URLs of websites that this bug affects.
Comment 12 Ricky Mondello 2023-01-25 15:20:46 PST
Hi folks!

This is resolved in Safari Technology Preview 162. At least, I made a code change in Safari that I *believe* resolves it. (I used the reproduction attached by Liam DeBeasi to test.)

Can all of y’all who care about this issue give your web content a spin with Safari Technology Preview 162 and report back about whether the AutoFill issue is resolved or not? I’d really appreciate that, and I also appreciate your patience.
Comment 13 Martin 2023-01-25 19:29:11 PST
Confirmed working in Safari Technology Preview Release 162 (Safari 16.4, WebKit 18615.1.18.2) on MacOS Ventura. 

Is there a way to test this on iOS?

Thank you, Ricky!!
Comment 14 Ricky Mondello 2023-01-30 07:10:36 PST
> Is there a way to test this on iOS?

Not at this time. I’ll try to bump this bug once the fix is testable in an iOS beta.
Comment 15 Steve 2023-03-07 09:51:47 PST
Ricky,
How long does it usually take for the fix in Safari Technology Preview to show up in Safari?
Comment 16 Ricky Mondello 2023-03-07 10:43:35 PST
macOS Ventura 13.3, iOS 16.4, and iPadOS 16.4 contain this fix.
Comment 17 Sunny Patel 2023-03-21 07:30:18 PDT
Ricky, thank you so much for this fix!

We noticed when building nested web components each with their own shadowDOM trees, that autofill still doesn't work.  Have you tested for this use case? It occurs quite often if you're building a web components using something like Lit or StencilJS
Comment 18 Ricky Mondello 2023-03-21 12:24:07 PDT
Thanks Sunny!

> We noticed when building nested web components each with their own shadowDOM trees, that autofill still doesn't work.  Have you tested for this use case? It occurs quite often if you're building a web components using something like Lit or StencilJS

I’m very motivated to get this fixed. Do you think you could create some kind of reduced test case, ideally a single HTML file, and attach it to this bug? That way, I’ll have something that represents exactly what you’d like to see work.
Comment 19 Sunny Patel 2023-03-22 07:27:19 PDT
Ricky, 

My apologies looks like it is fixed as well. 

Here's the test is used: https://9tmy5w-3333.csb.app

Worked fine in technology preview version, Release 165 (Safari 16.4, WebKit 18616.1.4.4). 

Thanks!
Comment 20 Ricky Mondello 2023-03-22 08:29:14 PDT
I’m so happy to hear that!
Comment 21 maxwell.benton@mastercard.com 2023-05-25 06:53:55 PDT
Hello Ricky,

I can open a separate ticket if you prefer, but one-time-code autofill in the shadow DOM still appears to not be fully working after testing on Safari 16.4 and now 16.5.

Here is an example with a minimal shadow DOM component alongside a regular HTML input for comparison: https://playcode.io/1482887

As of iOS 16.4, the code autofill suggestion now appears for the shadow DOM input, but clicking on the suggestion does not populate the element with the code.
Comment 22 Ricky Mondello 2023-05-25 08:56:36 PDT
Hi Maxwell.

You’ll find that this is fixed in the betas of Safari Version 16.6, as well as in Safari Technology Preview.
Comment 23 Ryosuke Niwa 2023-06-14 10:19:38 PDT
*** Bug 257804 has been marked as a duplicate of this bug. ***