Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-a11y-utils): prevent clicking on a Tooltip from closing the pa… #1905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ToMESSKa
Copy link
Contributor

@ToMESSKa ToMESSKa commented Mar 14, 2025

…rent dialog

INSTUI-4475

ISSUE:
-when user clicks on a Tooltip inside of a dialog with shouldCloseOnDocumentClick, the dialog closes

TEST PLAN:

  • copy test case below in the documentation
  • open the modal
  • hover over the text and button triggers and click on the appearing tooltips
  • the modal should remain open
  • the same example should result in closing the modal in the current version
  • Tooltip should have the same behavior (should close on Esc in a modal etc.)
  • the example should work with a Tray too (just replace the Modal tags with Tray)
 const TestModal = () => {
      const [open, setOpen] = useState(false)

      return (
         <div style={{ padding: "0 0 16rem 0" }}>
        <Button
          onClick={() => {setOpen(true)}}
        >
          Show the Modal
        </Button>

        <Modal
          label="modal"
          open={open}
          onDismiss={() => {setOpen(false)}}
          shouldCloseOnDocumentClick
        >
          <Modal.Header>
            <CloseButton
            placement="end"
            offset="small"
            screenReaderLabel="Close"
            onClick={() => {setOpen(false)}}
          />
            <Heading>Hello World</Heading>
          </Modal.Header>
          <View as="div" padding="medium" id="tray-content">
            <Tooltip
              renderTip="This is the tooltip text"
              mountNode={document.getElementById("tray-content")}
            >
              <Text>This text has a tooltip</Text>
            </Tooltip>

            <Tooltip
              renderTip="This is the tooltip text"
              mountNode={document.getElementById("tray-content")}
            >
              <Button>This button has a tooltip</Button>
            </Tooltip>
          </View>
        </Modal>
      </div>
      )
    }
    render(<TestModal />)

Copy link

PR Preview Action v1.6.0

🚀 View preview at
https://instructure.design/pr-preview/pr-1905/

Built to branch gh-pages at 2025-03-14 13:31 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ToMESSKa ToMESSKa self-assigned this Mar 14, 2025
@ToMESSKa ToMESSKa requested review from matyasf and balzss March 14, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant