Skip to content

Commit c8ea11d

Browse files
montezumekodiakhq[bot]
authored andcommitted
fix(tooltip): use defined variable (#997)
* chore: fix tooltip undefined var * chore: fix test * chore: typo in spec title
1 parent 9779d27 commit c8ea11d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/tooltip/tooltip.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const Tooltip = props => {
122122
);
123123

124124
const childrenProps = {
125-
'aria-describedby': open ? id : null,
125+
'aria-describedby': tooltipIsOpen ? id : null,
126126
// for seo and accessibility, we add the tooltip's title
127127
// as a native title when the title is hidden
128128
title:

src/components/tooltip/tooltip.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ describe('Tooltip', () => {
107107
).toBeInTheDocument();
108108
});
109109

110+
it('should not set aria-describedby on button when not open', () => {
111+
const { container } = render(
112+
<TestComponent id="my-tooltip" isOpen={false} />
113+
);
114+
expect(
115+
container.querySelector("[aria-describedby='my-tooltip']")
116+
).not.toBeInTheDocument();
117+
});
118+
110119
describe('interacting with mouse', () => {
111120
it('should show tooltip', () => {
112121
const onMouseOver = jest.fn();

0 commit comments

Comments
 (0)