Skip to content

Modal closing when clicking on content inside it #229

Closed
@cdellacqua

Description

I'm using a modal containing a form with a PasswordInput field. When clicking the show/hide password, the modal closes unexpectedly. I found out after some debugging that the problem is here:
(file Modal.svelte)

on:click={({ target }) => {
    if (!innerModal.contains(target)) {
      open = false;
    }
  }}

By clicking the "hide/show" icon inside the PasswordInput, that icon gets unmounted from the DOM so it can be replaced with another one indicating the opposite action. That causes the .contains method to return false, even though the source of the event was inside the modal when it was originally triggered. This should also apply to similar cases.

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions