Module

useModal

Members

boolean

# inner constant MODAL_OPEN_STATE

Enum representing the different open states of the modal.

Properties:
Name Type Description
OPENED boolean
CLOSED boolean

View Source hooks/useModal.js, line 12

Methods

# inner useModal(initialOpeningState, formId) → {ModalFeatures}

While the Modal component manages the structure of the modal, this hook manages its functionality. Such as opening and closing it and retrieving focus by the last focused element after it closes.

Parameters:
Name Type Description
initialOpeningState MODAL_OPEN_STATE
formId String

The id of the form that is part of the modal in order to reset it when the modal closes.

View Source hooks/useModal.js, line 58

An object containing the functionality of the modal.

ModalFeatures

Type Definitions

# clickOutsideCallback(event) → {void}

Parameters:
Name Type Description
event MouseEvent

View Source hooks/useModal.js, line 17

void
object

# ModalFeatures

Properties:
Name Type Description
isOpen boolean
openButtonRef React.MutableRefObject.<any>

Allows you to retrieve the reference of the button that opens the modal in order to restore the focus to it when the latter closes.

open VoidFunction
close VoidFunction
clickOutside clickOutsideCallback

Takes care of closing the modal when the user clicks on the backdrop.

View Source hooks/useModal.js, line 24