SuggestModalChooser<T, TOwner>
Unofficial
The component that manages suggestion selection, navigation and rendering for a suggestion owner.
A single runtime class backs both obsidian#SuggestModal’s chooser and obsidian#PopoverSuggest’s suggestions; the owner that constructed it is exposed as SuggestModalChooser.chooser. SuggestionContainer is this same type under the name the popover side uses.
Import:
import type { SuggestModalChooser } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface SuggestModalChooser<T, TOwner>Properties
| Property | Type | Description | |
|---|---|---|---|
| chooser | TOwner | The owner that constructed the chooser and renders and selects its suggestions. | |
| containerEl | HTMLDivElement | Container element the suggestion list is rendered into. | |
| selectedItem | number | Index of the currently selected suggestion. | |
| selectOnHover | boolean | Whether hovering a suggestion selects it. While false, SuggestModalChooser.onSuggestionMouseover does nothing. | |
| suggestions | HTMLDivElement[] | DOM elements for each suggestion row. | |
| values | null | T[] | Current suggestion values, or null if none. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addMessage(text) | HTMLDivElement | Display a message in the suggestion list. | |
| addSuggestion(value) | void | Add a suggestion value to the list. Does nothing while SuggestModalChooser.values is null. | |
| forceSetSelectedItem(index, evt?) | void | Set the selected item by index, scrolling it into view unless a non-keyboard event triggered the change. | |
| getSelectedElement() | HTMLDivElement | null | Get the DOM element of the currently selected suggestion. | |
| getSelectedValue() | null | T | Get the value of the currently selected suggestion. | |
| moveDown(evt) | false | void | Move selection to the next suggestion. | |
| moveUp(evt) | false | void | Move selection to the previous suggestion. | |
| onSuggestionClick(evt, suggestion) | void | Handle click on a suggestion element. | |
| onSuggestionMouseover(evt, suggestion) | void | Handle mouseover on a suggestion element. Does nothing while SuggestModalChooser.selectOnHover is false. | |
| pageDown(evt) | false | void | Move selection down by one page of visible items. | |
| pageUp(evt) | false | void | Move selection up by one page of visible items. | |
| renderSuggestions() | void | Empty the container and re-render one suggestion element per current value, re-applying the selection. | |
| setSelectedItem(index, evt?) | void | Set the selected item by index, clamping the index to within the suggestions array, then invoking SuggestModalChooser.forceSetSelectedItem. | |
| setSuggestions(values) | void | Empty the container and replace all suggestions with new values. | |
| shouldSelectOnHover(value) | this | Set whether hovering a suggestion selects it. | |
| useSelectedItem(evt) | boolean | Accept the currently selected suggestion. |
Links to this page: