Disable form submit manually for passwordless Safari #1968
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
The passwordless login window does not honor the "mustAcceptTerms" flag set to true on Safari. A user is still able to hit the return key to send the magic link. (note that the submit button remains correctly disabled). This issue is not present on the latest version of chrome.
Lock relys on the submit button being disabled to prevent a user from submitting the form when they hit Enter.
This works on Chrome and forms with more than one field (which is why it only effects Passwordless), but Safari has a rule that states: If you have one text input Safari will submit the form regardless of a disabled submit button. If you have two text inputs or more Safari will not submit the form if the submit button is dsiabled.
We can manually prevent the form from submitting by adding an additional check for
props.disableSubmitButton
- which should make the browsers behave the same. The risk is that we get a false positive ifprops.disableSubmitButton
is inadvertently set totrue
, but I can't see anywhere in Lock where that would be the case.References
Safari bugs: https://bugs.webkit.org/show_bug.cgi?id=9756 and https://bugs.webkit.org/show_bug.cgi?id=16886
fixes #1967
Testing
I've added some unit tests and checked that the regular Login/Signup forms are not inadvertently blocked when the
mustAcceptTerms
is disabled and the user switches between form types.Checklist