UseModalClose
katanakit-js / useModalClose
Function: useModalClose()
Section titled “Function: useModalClose()”function useModalClose(modalSelector, useRemoveDOM?): void;Defined in: infrastructure/dom/dom.service.ts:490
Closes a modal by adding the “hidden” class or removing it from the DOM. Clicking outside the modal or calling this function will hide it.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
modalSelector |
string |
undefined |
A CSS selector string for the modal element. |
useRemoveDOM? |
boolean |
false |
If true, removes the modal from the DOM entirely. If false, only adds the “hidden” class (CSS display: none). |
Returns
Section titled “Returns”void
Example
Section titled “Example”// Hide modal with CSS hidden class (keeps element in DOM)useModalClose(".modal-overlay", false);
// Remove modal from DOM completelyuseModalClose(".modal-overlay", true);