Skip to content

Commit

Permalink
Get attribute from trigger button and not event target (#1484)
Browse files Browse the repository at this point in the history
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
  • Loading branch information
koddsson and keithamus authored Oct 12, 2022
1 parent a4743fd commit ac33b43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/components/primer/alpha/modal_dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function clickHandler(event: Event) {
const button = target?.closest('button')

// If the user is clicking a valid dialog trigger
let dialogId = target.getAttribute('data-show-dialog-id')
if (target instanceof HTMLButtonElement && dialogId) {
let dialogId = button?.getAttribute('data-show-dialog-id')
if (button && dialogId) {
event.stopPropagation()
const dialog = document.querySelector<ModalDialogElement>(`#${dialogId}`)
if (dialog) {
const dialog = document.getElementById(dialogId)
if (dialog instanceof ModalDialogElement) {
dialog.openButton = button
dialog.show()
return
Expand Down

0 comments on commit ac33b43

Please sign in to comment.