     document.addEventListener 'keydown', @accessibility_on_keydown
 
     try 
-      modal.querySelector('input:not([disabled])').focus()
+      modal.querySelector('input:not([disabled])')?.focus()
     catch e 
       console.error e
 

  height: 100vh;
  z-index: 99999;
}
"""

window.Modal =

    window.scroll(0, @scroll_Y)


window.wrap_in_modal = (children) -> 
  DIV null,

    DIV 
      id: 'lightbox'

    DIV
      id: 'modal'
      ref: 'dialog'
      role: 'dialog'
      # 'aria-labeledby': 'AUTH_task'
      # 'aria-describedby': if options.goal then 'AUTH_goal'


      DIV
        id: 'modal-wrapper'
        style: 
          maxWidth: AUTH_WIDTH() 

        DIV
          id: 'modal-body'

          children

