question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[a11y]: Focus gets stuck in an interactive Tooltip in a Modal

See original GitHub issue

Package

carbon-components-react

Browser

Chrome

Operating System

MacOS

Package version

10.46

Automated testing tool and ruleset

Manual testing

Assistive technology

No response

Description

When I tab to a tooltip on a modal and that tooltip contains an interactive element e.g. a link or a button, there is no way to tab out of the tooltip. Also if I press ESC, the whole modal closes, rather than just the tooltip.

I expect to be able to dismiss the Tooltip and tab around the rest of the modal elements with just the keyboard as input. Note if I mouse click on the modal, the tooltip does close and I can navigate around the modal again.

ESC should only close the tooltip, not the complete modal. If the modal is used to enter data, the user input could be easily lost with the current behaviour.

WCAG 2.1 Violation

No response

CodeSandbox example

https://7yieq.csb.app/

Steps to reproduce

Use the code sandbox sample to reproduce this issue. Click on the button to open the modal. Then tab to the tooltip and try to tab out of it. It is not possible - focus is trapped inside the Tooltip. Press ESC and note that the modal also closes which is incorrect behaviour.

codeSandbox sample:

import React, { useState } from "react";
import { render } from "react-dom";
import { Button, Modal, Tooltip } from "carbon-components-react";

const App = () => {
  const [open, setOpen] = useState(false);
  return (
    <div>
      <Button onClick={() => setOpen(true)}>Open modal</Button>
      <Modal
        open={open}
        modalHeading="Add a custom domain"
        modalLabel="Account resources"
        primaryButtonText="Add"
        secondaryButtonText="Cancel"
        onRequestSubmit={() => setOpen(false)}
        onRequestClose={() => setOpen(false)}
      >
        <div>
          <Tooltip triggerText="tooltip text">
            <p>Tooltip text goes here </p>
            <a href="/">Learn More</a>
          </Tooltip>
          <p style={{ marginBottom: "1rem" }}>
            Custom domains direct requests for your apps in this Cloud Foundry
            organization to a URL that you own. A custom domain can be a shared
            domain, a shared subdomain, or a shared domain and host.
          </p>
        </div>
      </Modal>
    </div>
  );
};

render(<App />, document.getElementById("root"));

Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
teresamonahancommented, Oct 22, 2021

Thanks for reporting this in such detail @teresamonahan! This issue with esc bubbling has been addressed in #9875, should be released in 10.47

@tay1orjones Sorry I missed the duplicate issue in my search! Thanks for the fix 😃

1reaction
tay1orjonescommented, Oct 20, 2021

Thanks for reporting this in such detail @teresamonahan! This issue with esc bubbling has been addressed in https://github.com/carbon-design-system/carbon/pull/9875, should be released in 10.47

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to trap focus inside modal to make it ADA compliant
tab, shift + tab and enter key and focus should be trapped inside modal and should not go out after pressing tab key...
Read more >
Material UI Tooltip Stays Open after triggered Dialog is closed
The Tooltip works as intended until the IconButton is clicked. The Dialog pops up as it should but when the dialog is exited,...
Read more >
Using JavaScript to trap focus in an element | hidde.blog
One thing this spec sometimes recommends, is to trap focus in an element, for example in a modal dialog while it is open....
Read more >
Control focus with tabindex - web.dev
Try pressing the Tab key to navigate through your site. Are you able to reach all the interactive controls on the page? If...
Read more >
Tooltips in the time of WCAG 2.1 | Sarah Higley
Focus and hover ... The first step is to ensure that the visual display can be controlled by either a keyboard or a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found