From a2629bf8303c8b8a76e9626c1b45e91bc9b3795e Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Tue, 1 Sep 2026 08:01:14 +0900 Subject: [PATCH 1/2] fix: set aria-describedby when overlay is a falsy but valid node overlay values like 0 are valid renderable content, but the previous `overlay && open` check treated them as absent and skipped aria-describedby even while the tooltip was visible. --- src/Tooltip.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tooltip.tsx b/src/Tooltip.tsx index ac1ea87..fc67dcb 100644 --- a/src/Tooltip.tsx +++ b/src/Tooltip.tsx @@ -121,7 +121,7 @@ const Tooltip = React.forwardRef((props, ref) => { const getChildren: TriggerProps['children'] = ({ open }) => { const child = React.Children.only(children); const childAriaDescribedBy = (child.props as React.AriaAttributes)['aria-describedby']; - const ariaDescribedBy = [childAriaDescribedBy, overlay && open ? mergedId : undefined] + const ariaDescribedBy = [childAriaDescribedBy, overlay != null && open ? mergedId : undefined] .filter(Boolean) .join(' '); const ariaProps: React.AriaAttributes = { From 90a690230fa97f6363f79fd9c9bf2b702e606f34 Mon Sep 17 00:00:00 2001 From: Application-drop-up Date: Thu, 3 Sep 2026 09:57:26 +0900 Subject: [PATCH 2/2] feat: add new tests --- tests/index.test.tsx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 019854d..e4af8bf 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -597,6 +597,35 @@ describe('rc-tooltip', () => { expect(trigger).toHaveAttribute('aria-describedby', 'existing-description'); }); + it('should set aria-describedby when overlay is a falsy but valid node like 0', () => { + const { container } = render( + + + , + ); + + const trigger = container.querySelector('button'); + const describedBy = trigger.getAttribute('aria-describedby'); + expect(describedBy).toBeTruthy(); + expect(document.getElementById(describedBy)).toHaveTextContent('0'); + }); + + it('should not set aria-describedby when overlay is null or undefined', () => { + const { container: nullContainer } = render( + + + , + ); + expect(nullContainer.querySelector('button')).not.toHaveAttribute('aria-describedby'); + + const { container: undefinedContainer } = render( + + + , + ); + expect(undefinedContainer.querySelector('button')).not.toHaveAttribute('aria-describedby'); + }); + it('should preserve original props of children', () => { const onMouseEnter = jest.fn();