themesberg / themesberg/flowbite
Get reference to clicked element in modal onShow callback
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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