obsidian/modals/minimizable-modal
A wrapper that makes any Obsidian Modal minimizable to a floating bar — without breaking the modal’s blocking contract.
Obsidian’s Modal is blocking: while it is open the rest of the app is meant to be inert until the modal is dismissed. MinimizableModal wraps any modal instance (plain Modal, FuzzySuggestModal, the library’s ModalBase, your own subclass, … — including modals you do not own) and adds a minimize button. Minimizing hides the modal and its blocking backdrop and shows a small floating bar with a restore button (and, by default, a Cancel button that closes the wrapped modal — pass { shouldShowCancelButton: false } to hide it), so the user can peek at the notes/folders the operation involves — but the modal is NOT dismissed, so its blocking contract must be preserved.
To keep that contract while minimized, the wrapper puts the app into a peek-only lock: the user may mouse-click and scroll to inspect content, but cannot start anything new. While any modal is minimized the wrapper: - blocks the keyboard (typing, hotkeys, the command-palette shortcut), - blocks the right-click context menu, and - blocks opening any other modal (a re-fired command, the command palette, settings, …).
A blocked attempt flashes the floating bar and beeps so the user sees (and hears) why nothing happened. Restoring (or the modal closing) lifts the lock. This prevents, for example, minimizing a “merge folder” picker and then firing the same command again to stack several concurrent merges.
The wrapper reuses the modal’s own title (titleEl) as the minimized bar label, so set the title the usual way (modal.setTitle(...)). Render arbitrary content into Modal.contentEl, including clickable note links produced by renderInternalLink from obsidian-dev-utils/obsidian/markdown:
const modal = new MyModal(app);modal.setTitle('Merging notes');modal.contentEl.appendChild(await renderInternalLink({ app, pathOrAbstractFile: file }));
const minimizable = new MinimizableModal(modal);minimizable.modal.open();minimizable.minimize(); // a floating bar offers "restore"; the app is peek-only until restoredThe wrapped modal can still be closed normally; the floating bar is cleaned up automatically when the modal closes (even if it is closed while minimized).
Classes
Section titled “Classes”| Class | Description |
|---|---|
| MinimizableModal | 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. |
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| MinimizableModalConstructorOptions | Options for constructing a MinimizableModal. |