Skip to content

Screen reader does not announce tooltip text for trigger element when placed inside Modal #8915

@joonass-visma

Description

@joonass-visma

Provide a general summary of the issue here

Screen reader does not announce tooltip text for trigger element when placed inside Modal.

🤔 Expected Behavior?

Tooltip text should be announced no matter where the tooltip trigger element is placed.

😯 Current Behavior

Tooltip text is not announced for tooltip trigger element when placed inside Modal.

💁 Possible Solution

When tooltip overlay element gets added to DOM, it gets inert attribute because Modal has set up MutationObserver to hide dynamically added elements. This inert is probably preventing aria-describedby from working correctly because it now refers to tooltip element inside inert overlay element. If this is the cause, then adding some kind of exception to the hiding logic should fix it.

🔦 Context

No response

🖥️ Steps to Reproduce

  1. Set up a Modal with tooltip inside
import {Button, Dialog, DialogTrigger, Modal, OverlayArrow, Tooltip, TooltipTrigger} from 'react-aria-components';
import {Edit} from 'lucide-react';

<DialogTrigger>
  <Button>Open modal</Button>
  <Modal>
    <Dialog>
      <TooltipTrigger>
        <Button>
          <Edit size={18} />
        </Button>
        <Tooltip>
          <OverlayArrow>
            <svg width={8} height={8} viewBox="0 0 8 8">
              <path d="M0 0 L4 4 L8 0" />
            </svg>
          </OverlayArrow>
          Edit
        </Tooltip>
      </TooltipTrigger>
    </Dialog>
  </Modal>
</DialogTrigger>
  1. Open a screen reader (e.g. NVDA, VoiceOver)
  2. Tab the focus to the button inside modal
  3. Screen reader does not announce the tooltip text.

Version

react-aria-components 1.12.2

What browsers are you seeing the problem on?

Chrome, Firefox, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

Windows 11, NVDA, Narrator

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions