Skip to content

Commit 0524735

Browse files
committed
fix(unity-bootstrap-theme): added styles to hidden box
UDS-2010
1 parent 486628e commit 0524735

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/unity-bootstrap-theme/src/js/card-bodies.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,27 @@ function initCardBodies() {
4242
}
4343
visibleText = tempText + '...';
4444

45-
paragraph.setAttribute('aria-label', visibleText);
45+
// Create a new hidden element to store the truncated text
46+
const visibleTextElementId = `visible-text-${Math.random().toString(36).substring(7)}`;
47+
const visibleTextElement = document.createElement('div');
48+
visibleTextElement.id = visibleTextElementId;
49+
visibleTextElement.textContent = visibleText;
50+
visibleTextElement.style.position = 'absolute';
51+
visibleTextElement.style.top = `${paragraph.offsetTop}px`;
52+
visibleTextElement.style.left = `${paragraph.offsetLeft}px`;
53+
visibleTextElement.style.width = `${paragraph.offsetWidth}px`;
54+
visibleTextElement.style.height = `${paragraph.offsetHeight}px`;
55+
visibleTextElement.style.opacity = '0';
56+
visibleTextElement.style.pointerEvents = 'none';
57+
visibleTextElement.style.zIndex = '1';
58+
59+
// Add the hidden element to the DOM
60+
cardBody.appendChild(visibleTextElement);
61+
62+
paragraph.setAttribute('aria-describedby', visibleTextElementId);
63+
64+
// Hide the original paragraph from screen readers
65+
paragraph.setAttribute('aria-hidden', 'true');
4666

4767
}
4868
});

0 commit comments

Comments
 (0)