Hide tooltips on the Esc key (#26305)

* Hide the tooltip when Esc key is pressed

* Simplify ActionsDropdown

* Rename to tooltipDescription

* Use OLTooltip instead of Tooltip

GitOrigin-RevId: ee27cde2735ae3a0de5e37bfb8ab1dd99069742c
This commit is contained in:
Rebeka Dekany
2025-06-17 08:05:47 +00:00
committed by Copybot
parent aa4d8f4925
commit 9aa261eaf6
9 changed files with 90 additions and 79 deletions
@@ -32,4 +32,33 @@ describe('<OLTooltip />', function () {
cy.get('@blurHandler').should('have.been.calledOnce')
cy.findByText(description).should('not.exist')
})
it('hides the tooltip when Escape key is pressed', function () {
const description = 'Press Escape to close'
const btnText = 'Hover me!'
cy.mount(
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100vh',
}}
>
<OLTooltip id="esc" description={description}>
<button>{btnText}</button>
</OLTooltip>
</div>
)
cy.findByRole('button', { name: btnText }).as('button')
cy.get('@button').trigger('mouseover')
cy.findByText(description)
cy.get('@button').trigger('mouseout')
cy.get('@button').focus()
cy.findByText(description)
cy.get('body').type('{esc}')
cy.findByText(description).should('not.exist')
})
})