amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

form.clear not clearing the form state

Open shishirm opened this issue 8 years ago • 5 comments

What's the issue?

We are trying to use form.clear to clear the invalid state of a form. Basically, we have a form and upon invalid entries on the form, we are showing the user a lightbox (using the invalid event that the amp-form exposes). Upon closing the lightbox, we are trying to use form.reset, tied to the close event to reset the invalid state on the form, but it doesn't seem to be triggering the same.

We know this because without changing the invalid field, if we resubmit the form, then the lightbox is not shown again.

How do we reproduce the issue?

Create a form and use the invalid event to trigger some lightbox to show up. Tie the close of the lightbox to a form.clear. Resubmitting the form, will not cause the lightbox to be triggered as the form is already in an invalid state.

What browsers are affected?

All browsers and mobile devices.

Which AMP version is affected?

This was seen as recently as Version 1533253141109 but it likely exists prior to this as well.

shishirm avatar Aug 13 '18 21:08 shishirm

Hello! Thanks for letting us know what you're experiencing. Can you share a link to a document or some markup that shows the behavior you describe? It would help us figure out what's wrong more quickly.

cvializ avatar Aug 14 '18 14:08 cvializ

Hello,

Thanks so much for your prompt response. This is a sample page,

http://mshishir1.herokuapp.com/shop/amp_partner_lightbox.html#development=1

Basically, the steps to follow are,

  1. Enter an invalid zip code
  2. Click on the button
  3. Lightbox will show up. Close the lightbox and the zipcode will go away
  4. Reenter an invalid zipcode
  5. Click the button -> But the lightbox will not show up

The light box shows up in point 3 above because its display is tied to the invalid event on the form. The light box does not show up in point 5 above, because the form.clear tied to the close on the lightbox does not seem to clear the invalid event on the form.

Kindly let us know if you need additional details around this.

shishirm avatar Aug 14 '18 21:08 shishirm

This issue hasn't been updated in awhile. @cvializ Do you have any updates?

ampprojectbot avatar Nov 28 '18 02:11 ampprojectbot

Hi @shishirm thanks for opening this issue! I was able to reproduce it and agree with your assessment--removing the validity state classes on nested elements but not resetting the validity state on the form itself is inconsistent and buggy behavior.

Potential breakage: Actions listening to amp-form valid or invalid events will begin to experience these firing after the form has been cleared as opposed to now where they would not. In this use case this is precisely the fix we want for the buggy behavior, but it is possible other AMP pages might rely on current behavior. @nainar to weigh in

caroqliu avatar Jan 02 '20 22:01 caroqliu

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 Jun 30 '21 00:06 stale[bot]