Skip to content

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

Source code

notification.notification : boolean | object

The notification option configures the Notification plugin.

You can set the notification option to one of the following:

SettingDescription
falseDisable the Notification plugin
trueEnable the plugin with default options
An objectEnable the plugin and set stackLimit and animation
notification: Additional options
OptionTypeDefaultDescription
stackLimitnumber10Maximum visible toasts per corner. Extra requests are queued.
animationbooleantrueFade and slide animation when toasts appear.

Read more:

Default: false
Since: 17.1.0
Example

notification: true,

Methods

destroy

Source code

notification.destroy()

Clears queues and toast state, unregisters shortcuts and focus scope, and removes the host from the DOM.

disablePlugin

Source code

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

Source code

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

Source code

notification.getQueueSize() ⇒ number

Returns how many toasts are waiting in per-position queues.

hide

Source code

notification.hide(id)

Hides a toast by id.

ParamTypeDescription
idstringToast id returned from Notification#showMessage.

hideAll

Source code

notification.hideAll()

Hides every visible toast and clears all per-position queues.

isEnabled

Source code

notification.isEnabled() ⇒ boolean

Returns whether the notification setting is enabled for this instance.

isVisible

Source code

notification.isVisible([id]) ⇒ boolean

Returns whether a toast is visible, or whether any toast is visible when id is omitted.

ParamTypeDescription
[id]stringoptional Toast id.

showMessage

Source code

notification.showMessage(options) ⇒ string

Displays a toast. Returns the toast id, or an empty string when the toast is not shown.

Throws:

  • Error When options is invalid or actions are malformed.
ParamTypeDescription
optionsobjectToast options.
[options.variant]'info'
'success'
'warning'
'error'
optional Visual variant.
[options.title]stringoptional Optional title.
options.messagestring
HTMLElement
Main message body.
[options.duration]numberoptional 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]booleanoptional Whether the close control is shown.
[options.actions]Array<NotificationActionSpec>optional Action buttons.

updatePlugin

Source code

notification.updatePlugin([newSettings])

Rebuilds the plugin after settings change when notification options actually change.

ParamTypeDescription
[newSettings]objectoptional Settings object passed to updateSettings (partial).