MAIDR Documentation - v3.65.0
    Preparing search index...

    Class DisplayService

    Service for managing display focus, ARIA labels, and UI state transitions.

    Implements

    Index

    Constructors

    Properties

    plot: HTMLElement
    onChange: Event<FocusChangedEvent>

    Methods

    • Gets the instruction text for the plot.

      Parameters

      • OptionalincludeClickPrompt: boolean = true

        Whether to include the click prompt

      Returns string

      The instruction text

    • Enters label scope (TRACE_LABEL or FIGURE_LABEL) while preserving the current scope on the stack. This allows proper restoration when exiting label scope.

      Note: Label scopes are not pushed to focusStack (which only holds Focus types). The previous scope is preserved in focusStack and used when exiting.

      Parameters

      • labelScope: Scope

        The label scope to enter (TRACE_LABEL or FIGURE_LABEL)

      Returns void

    • Exits label scope and returns to the previous scope that was active before entering label mode.

      Uses the focusStack to determine the correct scope to return to, which preserves the scope that was active before entering label mode (e.g., TRACE, BRAILLE, etc.).

      Returns void

    • Syncs the focusStack to match the current scope without triggering a full focus change event. Use this when the scope has changed via Context (e.g., entering a subplot) but focusStack needs to stay in sync.

      Parameters

      • scope: Focus

        The scope to set as the current focus

      Returns void

    • Toggles focus between different scopes and manages the focus stack.

      Parameters

      • focus: Focus

        The focus scope to toggle to

      Returns void

    • Resets the focus stack to the given scope and moves focus to the plot element. Does not fire a display change event — the caller must call notifyFocusChange after completing any follow-up scope transitions (e.g. exitSubplot) to avoid emitting a stale intermediate scope.

      Parameters

      • targetScope: Focus

        The scope the focus stack should reflect after the modal is dismissed. The stack is reset to this value so it stays in sync with the hotkeys scope set by the caller.

        Important: The caller must ensure the hotkeys scope is set to targetScope (e.g. via context.exitSubplot()) before or immediately after this call. This method only updates the focus stack and DOM focus; it does not change the hotkeys scope.

      Returns void

    • Fires a deferred display change event with the given scope. The deferral (setTimeout 0) gives screen readers one event-loop cycle to process the preceding focus change before React unmounts the modal element (e.g. the braille textarea). Without this, NVDA/JAWS exit focus mode when the focused element disappears from the DOM.

      Cancels any previously pending notification to avoid stale events from rapid repeated calls.

      Parameters

      • scope: Focus

        The scope to emit as the new display focus

      Returns void