Skip to content

SuggestModal<T>

Official

A suggest modal.

Import:

import { SuggestModal } from 'obsidian';

Signature:

export class SuggestModal<T> extends Modal implements ISuggestOwner<T>

Extends: Modal

Implements: ISuggestOwner<T>

Constructor

new SuggestModal(app: App)

Constructor.

To extract the constructor type, use ExtractConstructor<SuggestModal>.

Properties

PropertyTypeDescription
appAppThe Obsidian app instance.
(Inherited from Modal)
bgElHTMLElementBackground applied to application to dim it
(Inherited from Modal)
bgOpacitystringOpacity percentage of the background
(Inherited from Modal)
chooserSuggestModalChooser<T, this>The suggestion chooser that manages selection and rendering.
clearButtonElHTMLDivElementButton element to clear the input field.
containerElHTMLElementThe container HTML element for the modal.
(Inherited from Modal)
contentElHTMLElementThe HTML element that represents the content of the modal.
(Inherited from Modal)
ctaElHTMLDivElementCall-to-action element displayed in the modal.
dimBackgroundbooleanWhether the background is being dimmed
(Inherited from Modal)
emptyStateTextstringThe text to display when there are no suggestions.
hasInitialInputFocusbooleanWhether the modal focuses its first input when opened.
(Inherited from Modal)
headerElHTMLDivElementHeader element of the modal dialog.
(Inherited from Modal)
inputElHTMLInputElementThe input element.
instructionsElHTMLDivElementElement displaying keyboard shortcut instructions.
isOpenbooleanWhether the suggest modal is currently open.
limitnumberThe limit of the number of suggestions.
modalElHTMLElementThe HTML element that represents the modal.
(Inherited from Modal)
resultContainerElHTMLElementThe result container element.
scopeScopeThe scope for the keymaps.
(Inherited from Modal)
selectionnull | WindowSelectionSelection logic handler
(Inherited from Modal)
shouldAnimatebooleanWhether the modal should animate
(Inherited from Modal)
shouldRestoreSelectionbooleanWhether the modal should restore the selection when it is opened or closed.
(Inherited from Modal)
titleElHTMLElementThe HTML element that represents the title of the modal.
(Inherited from Modal)
winnull | WindowReference to the global Window object.
(Inherited from Modal)

Methods

MethodReturnsDescription
animateClose()Promise<void>Performed when animation is complete
(Inherited from Modal)
animateOpen()Promise<void>Performed when animation is started
(Inherited from Modal)
close()voidClose the modal.
(Inherited from Modal)
getRootEl()HTMLElementGets the modal's root element.
(Inherited from Modal)
getSuggestions(query)Promise<T[]> | T[]Get the suggestions.
onChooseSuggestion(item, evt)voidChoose a suggestion.
onClickOutside(evt)voidCloses the modal when a click occurs outside of it, unless the event was already handled.
(Inherited from Modal)
onClose()voidCalled when the modal is closed.
(Inherited from Modal)
onEscapeKey()voidOn escape key press close modal
(Inherited from Modal)
onHistoryBack()voidCalled when the user navigates back in the history.
(Inherited from Modal)
onHistoryForward()voidCalled when the user navigates forward in the history.
(Inherited from Modal)
onInput()voidHandle input change in the suggest modal.
onNoSuggestion()voidSet the callback to be called when there are no suggestions.
onOpen()Promise<void> | voidCalled when the modal is opened.
(Inherited from Modal)
onSelectedChange(value, evt?)voidCalled after every selection change, including the programmatic one that follows SuggestModalChooser.setSuggestions.
onWindowClose()voidOn closing of the modal
(Inherited from Modal)
open()voidShow the modal on the the active window. On phones, the modal will animate on screen.
(Inherited from Modal)
renderSuggestion(value, el)voidRender a suggestion.
selectActiveSuggestion(evt)voidSelect the active suggestion.
selectSuggestion(value, evt)voidSelect a suggestion.
setBackgroundOpacity(opacity)thisSet the background opacity of the dimmed background.
(Inherited from Modal)
setCloseCallback(callback)thisSet the callback to be called when the modal is closed.
(Inherited from Modal)
setContent(content)thisSet the content of the modal.
(Inherited from Modal)
setDimBackground(dim)thisSet whether the background should be dimmed.
(Inherited from Modal)
setInstructions(instructions)voidSet the instructions.
setPlaceholder(placeholder)voidSet the placeholder text.
setTitle(title)thisSet the title of the modal.
(Inherited from Modal)
updateSuggestions()voidRefresh the displayed suggestions based on the current query.

Links to this page: