select-your-own-seat

Expand History Expand History
Collapse History Collapse History

Navigate when <dialog> element closes

When viewing seats through the page’s modal <dialog> element, closing the modal does not update the page’s URL. This means that after viewing a Seat’s details early on in a session, a User can navigate back to the Seats index, filter seats, remove Seats from their cart.

The whole time they’re taking action, they might not update the URL’s path. If they were to reload the page, they might be surprised to re-visit the last selected seat’s details in a modal <dialog> element.

This commit replaces the <form method="dialog"> element with an <a> element that links to the /venues/:venue_id/floors/:floor_id/seats URL.

Additionally, this commit handles the <dialog>‘s cancel event that’s triggered by esc, by introducing the dialog_controller.js file and declaring the data-action="cancel->dialog#cancel" attribute to route events to the dialog#cancel function.

Once events are routed to cancel, invoke Turbolinks.visit with the value of data-return-to-url.

In a JavaScript-disabled environment, clicking the “Close” button will navigate the user back to the Seats index, but a esc will not. Whoops!