JavaScript enhancements for the Button component

Hierarchy (View Summary)

Constructors

Properties

_$root: HTMLElement
_config: ButtonConfig
debounceFormSubmitTimer: number = null
defaults: ButtonConfig = ...

Button default config

elementType: new () => Element = HTMLElement
moduleName: string = 'govuk-button'

Name for the component used when initialising using data-module attributes.

schema: Readonly<{ properties: { preventDoubleClick: { type: "boolean" } } }> = ...

Button config schema

Accessors

Methods

  • Internal Virtual

    configOverride

    Function which defines configuration overrides to prioritize properties from the root element's dataset.

    It should take a subset of configuration as input and return a new configuration object with properties that should be overridden based on the root element's dataset. A Symbol is used for indexing to prevent conflicts.

    Parameters

    Returns ObjectNested

    return - Configuration object

  • Private

    Debounce double-clicks

    If the click quickly succeeds a previous click then nothing will happen. This stops people accidentally causing multiple form submissions by double clicking buttons.

    Parameters

    • event: MouseEvent

      Mouse click event

    Returns false

    Returns undefined, or false when debounced