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

Modal dialog link in radio button has inconsistent select behavior #1526

Closed
angela-tran opened this issue Jul 13, 2023 · 3 comments · Fixed by #2207
Closed

Modal dialog link in radio button has inconsistent select behavior #1526

angela-tran opened this issue Jul 13, 2023 · 3 comments · Fixed by #2207
Assignees
Labels
front-end HTML/CSS/JavaScript and Django templates

Comments

@angela-tran
Copy link
Member

There's some inconsistent behavior with closing the modal and what happens to the radio button.

See this GIF where I close the modal by:

  • clicking the X
  • pressing the Esc key
  • clicking off the modal

In the last case, the radio button gets selected.
benefits-login-gov-help-modal

Originally posted by @angela-tran in #1524 (comment)

Additional context

An attempt to fix this was made in #1524 by consuming the click event, but because the modal content has clickable elements, we can't use that solution.

@indexing
Copy link
Member

indexing commented Aug 8, 2023

@machikoyasuda Are we addressing this issue as part of our work to optimize the modal component?

@machikoyasuda
Copy link
Member

@indexing No. The modal component optimization is purely all CSS. There's nothing CSS can do to change this behavior. I believe this bug would require digging into Bootstrap JS and writing some custom JS to change the behavior.

@machikoyasuda machikoyasuda added the front-end HTML/CSS/JavaScript and Django templates label Aug 15, 2023
@machikoyasuda machikoyasuda self-assigned this Jul 9, 2024
@machikoyasuda
Copy link
Member

I think I figured out the issue: https://codepen.io/machikoyasuda/pen/vYqENKx

Clicking on the backdrop part of the modal div also triggers clicking on the radio button. The default event bubbling from this click needs to be prevented manually. But also, clicking on the Login.gov text link in the modal shouldn't be deleted. So I came up with this code so far:

$("#modal--login-gov").on('click', function(event) {
    console.log("clicked modal 1");
    console.log(event.target);
    if (!(event.target instanceof HTMLAnchorElement)) {
       event.preventDefault();
       event.stopPropagation();
   }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end HTML/CSS/JavaScript and Django templates
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants