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

netteForms.js on Android does not correctly focus required inputs #275

Closed
valekj opened this issue Aug 5, 2021 · 9 comments
Closed

netteForms.js on Android does not correctly focus required inputs #275

valekj opened this issue Aug 5, 2021 · 9 comments

Comments

@valekj
Copy link

valekj commented Aug 5, 2021

Version: 3.1

Bug Description

If you forget to fill a required input on Android, said input is not correctly focused afterwards (no css is applied) and you can't see what you are typing.
Happens on Android 10 and 11 (Chrome), works correctly on iOS and desktop.
If you comment out netteForms.js and keep browser validation, it works as expected even on Android.

Steps To Reproduce

Open a form that uses netteForms.js (for example https://nette.org/cs/sign-in).
Don't fill any input and submit the form.
Javascript warning pops up informing you about missing inputs.
Click ok.
Start typing.

Expected Behavior

Required input should be focused, css should be applied and when you start typing, you should see the letters.

@dg
Copy link
Member

dg commented Aug 8, 2021

This is a Chrome issue that also affects Windows. The reason is that alert() loses focus.

Maybe it is related to https://developers.google.com/web/updates/2017/03/dialogs-policy

@dg
Copy link
Member

dg commented Aug 12, 2021

@valekj what returns console.log(navigator.userAgentData) and console.log(!!HTMLDialogElement.prototype.showModal) in affected browsers?

@valekj
Copy link
Author

valekj commented Aug 23, 2021

Hi, sorry for the delay.

Here are the console logs from android phone (s10e, android 11, chrome 92.0.4515.159):

console.log(navigator.userAgentData):
returns an object, however when I try to convert it to JSON, I just get an empty object, so here is a screenshot:

consolelog

console.log(!!HTMLDialogElement.prototype.showModal):
returns "true"

Chrome (92.0.4515.159) on Windows 10 does not seem to be affected on my end.

dg added a commit that referenced this issue Aug 24, 2021
@dg
Copy link
Member

dg commented Aug 24, 2021

Can you test that this netteForms.js works properly on Android?
https://github.com/nette/forms/tree/master/src/assets

@valekj
Copy link
Author

valekj commented Aug 24, 2021

It focuses the input correctly now, however the dialog looks a bit weird:

scrshot

Also, would it be possible to target mobile Brave as well? Unfortunately it does not have any identification in Brands property.

brave

@dg
Copy link
Member

dg commented Aug 24, 2021

I can target all mobile Chromium browsers.

Unfortunately I don't have Android and I don't know how to fix the design. Can you give it a try?

dg added a commit that referenced this issue Aug 24, 2021
dg added a commit that referenced this issue Aug 24, 2021
dg added a commit that referenced this issue Aug 24, 2021
@valekj
Copy link
Author

valekj commented Aug 24, 2021

It's nothing fancy, but what about this:

centereddialog

style.innerText = '.netteFormsModal { text-align: center; margin: auto; width: 80%; border: 1px solid #000; padding: 1rem; } .netteFormsModal button { padding: .1em 2em }';

dg added a commit that referenced this issue Aug 25, 2021
dg added a commit that referenced this issue Aug 25, 2021
@dg
Copy link
Member

dg commented Aug 25, 2021

In the meantime, please add the style to your CSS file and we will tweak the resulting style over time.

@valekj
Copy link
Author

valekj commented Aug 25, 2021

thank you!

@dg dg closed this as completed Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants