Skip to content

Commit 2c1e758

Browse files
committed
fix(Tooltip): improve aria attribute handling for better accessibility
- Updated the logic for modifying the existing aria attribute to use split and filter methods, ensuring that the specified ID is removed correctly.
1 parent 4fccfd9 commit 2c1e758

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-core/src/components/Tooltip/Tooltip.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ export const Tooltip: React.FunctionComponent<TooltipProps> = ({
210210
if (!existingAria) {
211211
return;
212212
}
213-
const newAria = existingAria.replace(new RegExp(`\\b${id}\\b`, 'g'), '').trim();
213+
const newAria = existingAria
214+
.split(/\s+/)
215+
.filter((token) => token !== id)
216+
.join(' ');
214217
if (newAria) {
215218
element.setAttribute(attributeName, newAria);
216219
} else {

0 commit comments

Comments
 (0)