themesberg / themesberg/flowbite

Closing a Modal whose close button is in an HTML content located elsewhere inserted into the DOM via HTMX

Open
#616 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

<form hx-post="{% url 'my_nice_url' %}" hx-target="this" hx-swap="innerHTML">
    {% include "../partials/some-form.html" %}
</form>

In some-form.html I have :

<div>
    <button type="submit">Update</button>
    <button data-modal-hide="modal-myModal" type="button">Close</button>
</div>

If I click the update button, I'll get the confirmation displayed via HTMX and it contains a close button - close button being :

<button data-modal-hide="modal-myModal" type="button">Close</button>

But clicking on the close button on form POST doesn't close the form.

Is this because the button is located in a file elsewhere which get updated into the DOM via HTMX ?

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

Reproduce the issue using the form and partial snippets shown, including the HTMX innerHTML swap and the data-modal-hide button. Start by inspecting Flowbite’s modal close handling and how it finds buttons after DOM replacement; done means the close button in the swapped content closes the modal reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript, tailwindcss
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.