epic-power-rpg / roll20

Apache License 2.0
0 stars 0 forks source link

Add clickable popover backdrop #57

Closed jazeee closed 1 year ago

jazeee commented 1 year ago

Fix Add clickable popover backdrop #56

Clicking outside of the popover should close it. Also, add a title, spell name, and close button to popover.

image

https://user-images.githubusercontent.com/5629800/211223423-56f3ae6b-ebef-4b09-a878-117929c43f9d.mp4

Popover backdrops are a bit tricky in Roll20. My original attempt was to do <button class="popoverBackdrop">Click me</button> However, this fails in Roll20

Uncaught TypeError: Cannot read properties of null (reading 'dataset')
    at HTMLButtonElement.<anonymous> (vtt.bundle.js:formatted:556749:45)
    at HTMLBodyElement.dispatch (jquery-1.9.1.js:3074:9)
    at elemData.handle (jquery-1.9.1.js:2750:28)

And looking at the source code: The error occurs here: else if ($(this)[0].offsetParent.dataset.reprowid) { which fails due to offsetParent being undefined.

Buttons in general, appear to need a parent.

Instead, to work around this, I add a parent div, with position: fixed, which solves this issue.