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

Provide a generic action to focus/reveal elements #7626

Closed
sebastianbenz opened this issue Feb 17, 2017 · 6 comments
Closed

Provide a generic action to focus/reveal elements #7626

sebastianbenz opened this issue Feb 17, 2017 · 6 comments

Comments

@sebastianbenz
Copy link
Contributor

Make it possible to focus/reveal specific elements via action. Here are three scenarios in which this would be very helpful:

  1. Scroll to element after form submit success: A form adds elements to a list, on successful submit the new element should be revealed (even if it requires scrolling the page). This is necessary in case the form input field is on a different position on the page than the results.

    <form ... on="submit-success:last-element-in-result-list.focus" ...>
    
  1. Show last element in a sub view: amp-bind makes it possible to implement master/detail views. This would work even better if once could reveal specific elements on the detail view:

    <button on="tap:AMP.setState(showProduct=1234),product-1234.focus" ..>
    
  2. Focus form input fields in lightbox: lightboxes are great for form inputs, make it possible to set focus to a specific form input field once the lightbox opens:

    <button on="tap:enter-details.showLightbox,form-details-name.focus" ..>
    

//cc @ericlindley-g

@aghassemi
Copy link
Contributor

@ericlindley-g this aligns nicely with some of the FR @alanorozco is doing this sprint (#7027, #649) so I suggest Prioritized FR milestone.

@ericlindley-g
Copy link
Contributor

+1 This would be great — particularly if we could smoothly animate the scrolling into view (as opposed to a "jump cut")

@alanorozco
Copy link
Member

alanorozco commented Feb 23, 2017

This is a great idea and it seems like it's almost a requisite to make the amp-bind story really useful.

One small caveat re: our current implementation of actions. Since originally only one action per event was supported, chaining actions wouldn't be a problem. Currently, action results can potentially be asynchronous so certain user expectations would not be matched since the action sequence is executed synchronously.

This needs more thought to answer whether we're ok with this. If we're not, then a more robust promise-chaining mechanism is needed.

This is more relevant for #649, but the case presented here made me think of this.

@aghassemi
Copy link
Contributor

@aghassemi
Copy link
Contributor

@spacedino UX might be needed for the animation curve of the smooth scrolling. Chrome is also adding this feature, We might be able to just borrow the curve from their implementation.

@aghassemi
Copy link
Contributor

@sebastianbenz @ericlindley-g FYI, feature merged today, will be in Canary this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants