themesberg / themesberg/flowbite

Get reference to clicked element in modal onShow callback

Open
#1,007 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
9.4k
Forks
862
PR merge metrics
No merged PRs in 30d

Description

Would be nice get a reference to the element that was clicked (if available) to trigger Modal.show() in the callback function.

Something like:

<button id="modalToggleId" data-modal-target="modalEl" data-modal-toggle="modalEl">...</button>

<div id="modalEl">...</div>

<script>
    modalOptions = {
        onShow: (clickedElement: HTMLElement | undefined) {
            if (clickedElement) {
                clickedElement.innerHtml = "Clicked";
            }
        },
    }
    const modal = new Modal(document.getElementById("modalEl"), modalOptions);
</script>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Modal.show entry point and the onShow callback implementation described in the issue. Trace how the clicked element is available, then verify that onShow receives it when Modal.show() is triggered through the data-modal-toggle markup; done means the callback can safely use the element when one exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript, typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.