Skip to content

Commit

Permalink
Use classes for modal too
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 2, 2024
1 parent c0f0a56 commit c2342d1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/js/handlebars/templates/modal-layout.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="modal" class="modal" tabindex="-1">
<div class="modal" tabindex="-1">
<div class="modal-contents">
<div class="modal-header">
<div class="modal-title"></div>
Expand Down
10 changes: 5 additions & 5 deletions assets/js/modal.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { qs } from './helpers'

const MODAL_SELECTOR = '#modal'
const MODAL_CLOSE_BUTTON_SELECTOR = '#modal .modal-close'
const MODAL_TITLE_SELECTOR = '#modal .modal-title'
const MODAL_BODY_SELECTOR = '#modal .modal-body'
const MODAL_SELECTOR = '.modal'
const MODAL_CLOSE_BUTTON_SELECTOR = '.modal .modal-close'
const MODAL_TITLE_SELECTOR = '.modal .modal-title'
const MODAL_BODY_SELECTOR = '.modal .modal-body'
const FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
const state = {
prevFocus: null,
Expand Down Expand Up @@ -38,7 +38,7 @@ function renderModal () {
qs(MODAL_SELECTOR).addEventListener('click', event => {
const classList = event.target.classList
// if we clicked on the modal overlay/parent but not the modal content
if (classList.contains('modal') && classList.contains('shown') && classList.length === 2) {
if (classList.contains('modal')) {
closeModal()
}
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions formatters/html/dist/html-BHYOTRCH.js

Large diffs are not rendered by default.

0 comments on commit c2342d1

Please sign in to comment.