amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-bind: Support title and URL change in AMP.pushState

Open eduardogoncalves opened this issue 5 years ago • 12 comments

At history.pushState we can pass URL history.pushState(stateObj, title, URL); to change URL in browser without navigating away from page.

Could AMP implement it?

Ex.: In a SPA, an user select Tweets tab, and url change to /tweets, then select Agenda and url change to /agenda.

image

eduardogoncalves avatar Jul 27 '19 16:07 eduardogoncalves

@cvializ worthy to keep in mind as part of stateful AMP pages.

nainar avatar Jul 29 '19 20:07 nainar

I think some aspects of this FR are already implemented in amp-bind with the AMP.pushState and AMP.popState actions. https://amp.dev/documentation/components/amp-bind/?referrer=ampproject.org#modifying-history-with-amp.pushstate()

But I believe it only allows the back/forward buttons to update the state, the URL and title are not updated at this time

cvializ avatar Jul 29 '19 20:07 cvializ

That's correct. Also we'd need viewer coordination to update title and hash.

dreamofabear avatar Jul 29 '19 20:07 dreamofabear

+1 At BringFido, title/url updating on state change (when not being shown from an amp cache) is the last mission-critical thing we can't pull off in AMP.

chasefinch avatar Nov 13 '19 21:11 chasefinch

The original API proposal: https://github.com/ampproject/amphtml/issues/9128#issuecomment-320332045

dreamofabear avatar Nov 13 '19 21:11 dreamofabear

From an AMP-first perspective, many websites have a search/filter functionality which updates the URL so that it can be easily shared with filters pre-applied.

Similarly, all Shopify websites update the URL with ?variant={{variant.id}} so that when sharing a page with friends, the recipient auto-selects the proper variant.

If a user lands on a product page, clicks a new variant, and wants to share it with a friend, they'd likely share it by copying the address bar URL.

For websites that do URL updating, it does seem especially useful.

Is this intended on being implemented any time soon? From what I gather above, it's currently deemed impossible?

stephengardner avatar Apr 25 '20 06:04 stephengardner

Definitely possible, just hasn't been prioritized yet.

Similarly, all Shopify websites update the URL with ?variant={{variant.id}}

I think this can be done today with amp-list and a QUERY_PARAM variable substitution in the src attribute, though it would fire a network request.

dreamofabear avatar Apr 26 '20 01:04 dreamofabear

This feature would be really awesome.

dennisP2ER avatar Mar 10 '21 16:03 dennisP2ER

This would be extremely useful if it could be finished and rolled out. Between some of the comments and the existing amp-bind AMP.pushState() functionality it appears many of the fundamentals have been tackled.

Any chance of being re-prioritised, please? It feels like one of those small steps that actually would make AMP that larger step more usable and comprehensive in the real world.

AaronMLB avatar Aug 18 '21 15:08 AaronMLB

Any updates here?

ydnikolaev avatar Oct 17 '21 10:10 ydnikolaev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 16 '22 07:10 stale[bot]

Bump

chasefinch avatar Oct 18 '22 15:10 chasefinch

https://twitter.com/marcan42/status/1581244983528820741?cxt=HHwWisDUoen72vErAAAA

digitalheir avatar Oct 19 '22 16:10 digitalheir