Notification
Description
The Notification plugin shows non-blocking toast messages anchored to the Handsontable root.
Enable it with the Options#notification option. Toasts are exposed to assistive technologies with
aria-live and do not take keyboard focus when they appear; use F6 to move focus into the notification region
for the grid that currently contains keyboard focus (with several instances on one page, each grid only handles F6
for its own focus scope, except when a single grid is on the page and focus is outside every grid).
Tab / Shift+Tab between controls, Escape to leave, and programmatic hide restores focus like Escape
when the last toast closes while focus is in the region.
Example
const hot = new Handsontable(container, { data: data, notification: true, licenseKey: 'non-commercial-and-evaluation',});const notification = hot.getPlugin('notification');notification.showMessage({ message: 'Saved.' });Options
notification
notification.notification : boolean | object
The notification option configures the Notification plugin.
You can set the notification option to one of the following:
| Setting | Description |
|---|---|
false | Disable the Notification plugin |
true | Enable the plugin with default options |
| An object | Enable the plugin and set stackLimit and animation |
notification: Additional options
| Option | Type | Default | Description |
|---|---|---|---|
stackLimit | number | 10 | Maximum visible toasts per corner. Extra requests are queued. |
animation | boolean | true | Fade and slide animation when toasts appear. |
Read more:
Default: false
Since: 17.1.0
Example
notification: true,Methods
destroy
notification.destroy()
Clears queues and toast state, unregisters shortcuts and focus scope, and removes the host from the DOM.
disablePlugin
notification.disablePlugin()
Hides all toasts, removes shortcuts and listeners, and destroys the UI host.
hideAll() must run before super.disablePlugin() because BasePlugin.disablePlugin() clears
this.enabled first, and hideAll() relies on the plugin still being enabled. The superclass
call then removes hooks and clears the shared EventManager.
enablePlugin
notification.enablePlugin()
Installs the notification host, document focusin listener (tab order + prior-focus for click paths), shortcuts
(F6 via grid + global shortcut contexts, Escape, Tab, Shift+Tab), and the focus scope.
getQueueSize
notification.getQueueSize() ⇒ number
Returns how many toasts are waiting in per-position queues.
hide
notification.hide(id)
Hides a toast by id.
| Param | Type | Description |
|---|---|---|
| id | string | Toast id returned from Notification#showMessage. |
hideAll
notification.hideAll()
Hides every visible toast and clears all per-position queues.
isEnabled
notification.isEnabled() ⇒ boolean
Returns whether the notification setting is enabled for this instance.
isVisible
notification.isVisible([id]) ⇒ boolean
Returns whether a toast is visible, or whether any toast is visible when id is omitted.
| Param | Type | Description |
|---|---|---|
| [id] | string | optional Toast id. |
showMessage
notification.showMessage(options) ⇒ string
Displays a toast. Returns the toast id, or an empty string when the toast is not shown.
Throws:
ErrorWhenoptionsis invalid or actions are malformed.
| Param | Type | Description |
|---|---|---|
| options | object | Toast options. |
| [options.variant] | 'info' 'success' 'warning' 'error' | optional Visual variant. |
| [options.title] | string | optional Optional title. |
| options.message | string HTMLElement | Main message body. |
| [options.duration] | number | optional Auto-dismiss delay in ms. 0 keeps the toast until dismissed manually. |
| [options.position] | 'top-start' 'top-end' 'bottom-start' 'bottom-end' | optional Corner stack. |
| [options.closable] | boolean | optional Whether the close control is shown. |
| [options.actions] | Array<NotificationActionSpec> | optional Action buttons. |
updatePlugin
notification.updatePlugin([newSettings])
Rebuilds the plugin after settings change when notification options actually change.
| Param | Type | Description |
|---|---|---|
| [newSettings] | object | optional Settings object passed to updateSettings (partial). |