Skip to content

MinimizableModal<TModal>

Wraps a Modal instance to make it minimizable to a small floating bar and restorable. While minimized the app is put into a peek-only lock (keyboard, context menu, and opening other modals are blocked) so the modal’s blocking contract is preserved.

Import:

import { MinimizableModal } from 'obsidian-dev-utils/obsidian/modals/minimizable-modal';

Signature:

export class MinimizableModal<TModal extends Modal>

Constructor

new MinimizableModal(modal: TModal, options?: MinimizableModalConstructorOptions)

Wraps the given modal, adding a minimize button and wiring up cleanup on close.

Properties

PropertyTypeDescription
closePatchComponentMonkeyAroundComponentPatches the wrapped modal's onClose to run cleanup. Persists for the wrapper's whole life (a modal can be reopened, so the patch must survive each close), hence a dedicated component that is never unloaded — distinct from peekLockComponent, whose patches live only while minimized. Exposed to subclasses so they can register additional lifetime-scoped patches on the wrapper.
modalTModalThe wrapped modal. Open, close, and populate it as usual (e.g. minimizable.modal.open()).

Methods

MethodReturnsDescription
minimize()voidMinimizes the modal: hides the modal and its backdrop, shows a floating bar with a restore button, and puts the app into the peek-only lock. A no-op if the modal is already minimized.
restore()voidRestores the modal from the minimized state, removing the floating bar and lifting the peek-only lock. A no-op if the modal is not minimized.

Links to this page: