File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
packages/unity-bootstrap-theme/src/js Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments