ui/Cancelable

Exports the ui/Cancelable.Cancelable Higher-order Component (HOC).

import Cancelable from '@enact/ui/Cancelable';

Members

CancelableHigher-Order Component

ui/Cancelable.Cancelable is a Higher-order Component that allows mapping a cancel key event to existing event handler either directly or via a custom function which can adapt the event payload.

The onCancel config option is required.

import Cancelable from '@enact/ui/Cancelable';
Configuration
onCancel
StringFunction

If it is a string, the cancel handler will attempt to invoke a function passed as a prop of that name. If it is a function, that function will be called with the current props as the only argument.

If the function handles the cancel action, it should returning true to prevent container or modal Cancelable instances from also handling the action.

modal
String

When true, the Cancelable instance will handle cancel events globally that successfully bubble up to window regardless of which component is focused.

modal cancel handlers are processed in reverse of the order they are created such that the innermost instance (in terms of the component hierarchy) have the first opportunity to handle the event before its container components.

Default: false
component
StringFunction

When set, the Wrapped component will be contained within an instance of component. This may be necessary if the props passed to Wrapped are not placed on the root element.

Default: null

addCancelHandlerFunction

addCancelHandler(handler)

Adds an event handler to filter cancel events.

1 Param
handler Function

Function that will receive the event and should return false if the event is a cancel event.

removeCancelHandlerFunction

removeCancelHandler(handler)

Removes an event handler to filter cancel events

1 Param
handler Function

A previously added filter function

ArrayBooleanFunctionModuleNumberObjectString