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
Fix inputs with the autofocus attribute #11908
Conversation
extensions/amp-form/0.1/amp-form.js
Outdated
@@ -251,6 +257,13 @@ export class AmpForm { | |||
|
|||
/** @private */ | |||
installEventHandlers_() { | |||
this.viewer_.whenFirstVisible().then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want autofocus to take effect everytime document becomes visible (think viewer swipes). whenNextVisible
does that (and covers first visibility as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right; I thought it was just once after the next time it became visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the document state reset between viewer swipes? i.e. would the user expect the field to autofocus again if they swipe to the next document and then swipe back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh naming! :) if you can think of a shorter version of ifAlreadyVisibleOrWhenNextVisible
, we can rename. it is a fairly new feature and not used in many places yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha yeah one of the hardest problems
* Fix inputs with the autofocus attribute * Use whenNextVisible instead
* Fix inputs with the autofocus attribute * Use whenNextVisible instead
Fixes #11892
It was a quick hit so I went ahead and made a PR