Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/clarity-js/src/interaction/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ function text(element: Node): TextInfo {
// Finally, send only first few characters as specified by the Setting
output = trimmedText.substring(0, Setting.ClickText);
isFullText = output.length === trimmedText.length;
} else if (element.nodeType === Node.ELEMENT_NODE) {
// If no regular text content is found and the element is an HTMLElement, attempt to get text from the 'aria-label' attribute.
const htmlElement = element as HTMLElement;
const ariaLabel = htmlElement.getAttribute('aria-label');

// If an 'aria-label' is found, process it similarly
if (ariaLabel) {
const trimmedAriaLabel = ariaLabel.replace(/\s+/g, Constant.Space).trim();
output = trimmedAriaLabel.substring(0, Setting.ClickText);
isFullText = output.length === trimmedAriaLabel.length;
}
}
}

Expand Down