amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

History handling in AMP Pages

Open cw-ashish-sharma opened this issue 6 years ago • 10 comments

I have a popup form that needs to be closed on browser back. but the problem is i just want to close the form and not go back to the previous values of the states. for example: lets say I have a form Basic Details with fields Name, Age, Mobile: the user sets the data i have another state isDataAvailable: used to keep track if the user has already filled the data and a field IsBasicDetailsPopUpShown: flag to show the popup

Initially the states will be :

{'name':"",'age':"",'mobile':"","isDataAvailable":false,"isBasicDetailsPopUpShown":false}

when i want to show the popup, I use AMP.PushState

{'name':"",'age':"",'mobile':"","isDataAvailable":false,"isBasicDetailsPopUpShown":true}

and then when the user fills the data i use AMP.setState

{'name':"dummy",'age':"10",'mobile':"999234234","isDataAvailable":true,"isBasicDetailsPopUpShown":true}

now when the user clicks on browser back i want only the 'isBasicDetailsPopUpShown' to be set to false

now on browser back the history will be poped out and will result in

{'name':"",'age':"",'mobile':"","isDataAvailable":false,"isBasicDetailsPopUpShown":false}

thus losing the data. Is there anyway to get around it?

cw-ashish-sharma avatar Aug 21 '20 18:08 cw-ashish-sharma

@choumx can you please help me?

cw-ashish-sharma avatar Aug 22 '20 04:08 cw-ashish-sharma

@choumx any update on this?

cw-ashish-sharma avatar Aug 26 '20 07:08 cw-ashish-sharma

@choumx can we do someting similar to what is done in amp-lightbox? is it possible to do it?

cw-ashish-sharma avatar Aug 28 '20 07:08 cw-ashish-sharma

@choumx any suggestions on this?

cw-ashish-sharma avatar Aug 31 '20 08:08 cw-ashish-sharma

@catherinehoule any suggestion on this?

cw-ashish-sharma avatar Sep 02 '20 10:09 cw-ashish-sharma

@cw-ashish-sharma sorry for the delay, I'm sorry, off-hands I don't have a solution for you. I only worked on the accessibility part (mostly focus management) of the lightbox.

catherinehoule avatar Sep 04 '20 14:09 catherinehoule

I have noticed that if we push a state that was previously not available and later when we do AMP.goBack we get that value. are we merging the states that were not there previously? for example: initial state

{
"name":"dummy",
}

we push another state via AMP.pushState

{
"name":"dummy_1",
"rollNo":56
}

now we do AMP.goBack()

the resulting state is

{
"name":"dummy",
"rollNo":56
}

is this correct and relevant?

cw-ashish-sharma avatar Sep 04 '20 19:09 cw-ashish-sharma

@choumx @catherinehoule could you please direct me somewhere I could get a solution for this?

cw-ashish-sharma avatar Sep 04 '20 19:09 cw-ashish-sharma

I’m sorry, I’m not working for amp. I just did a contribution to help accessibility on one component we were using...

catherinehoule avatar Sep 05 '20 17:09 catherinehoule

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 Mar 12 '22 12:03 stale[bot]