Skip to content

DisclosureMenuToggle

A link or button that controls the visibility of a DisclosureMenu.

Note

This is a subclass of BaseMenuToggle.

Constructor

Constructs a new DisclosureMenuToggle.

js
new DisclosureMenuToggle({
  menuToggleElement,
  parentElement,
  controlledMenu,
  parentMenu,
  initialize,
});

The constructor will call BaseMenuToggle's constructor with the provided options. It will also initialize the menu toggle if the initialize flag is set to true.

Parameters

NameTypeDescriptionDefault
optionsobjectThe options for generating the menu toggle.undefined
options.menuToggleElementHTMLElementThe toggle element in the DOM.undefined
options.parentElementHTMLElementThe element containing the controlled menu.undefined
options.controlledMenuDisclosureMenuThe menu controlled by this toggle.undefined
options.parentMenuDisclosureMenu, nullThe menu containing this toggle.null
options.initializebooleanA flag to initialize the menu toggle immediately upon creation.true

Initialize

The initialize method is inherited from the BaseMenuToggle class. There are no customizations for the DisclosureMenuToggle class.

Properties

Properties are inherited from the BaseMenuToggle class. There are no custom properties for the DisclosureMenuToggle class.

Getters and Setters

Getters and setters are inherited from the BaseMenuToggle class. There are no custom getters and setters for the DisclosureMenuToggle class.

Methods

Methods are inherited from the BaseMenuToggle class. The following methods are unique to or overwritten in the DisclosureMenuToggle class.

_setAriaAttributes protected

Sets the ARIA attributes on the toggle and controlled menu.

js
DisclosureMenuToggle._setAriaAttributes();

Calls the BaseMenuToggle's _setAriaAttributes method.

Ensures the toggle element has a role of "button" if it is not already a button.

Then using the toggle and menu's IDs, the toggle's aria-controls is set to the menu's ID.

open public

Opens and controlled menu.

js
DisclosureMenuToggle.open();

Calls the closeSiblings (inherited) method and then BaseMenuToggle's open method.

preview public

Opens the controlled menu without the current focus entering it.

js
DisclosureMenuToggle.preview();

Calls the closeSiblings (inherited) method and then BaseMenuToggle's preview method.

close public

Closes the controlled menu.

js
DisclosureMenuToggle.close();

Calls the closeChildren (inherited) method and then BaseMenuToggle's close method.