Skip to content

Commit 040feb3

Browse files
Copilotpattonwebz
andcommitted
Fix multiple accessibility icons stacking by implementing inline positioning
Co-authored-by: pattonwebz <3902039+pattonwebz@users.noreply.github.com>
1 parent a11517c commit 040feb3

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/frontendHighlighterApp/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ class AccessibilityCheckerHighlight {
296296
document.body.append( tooltip );
297297

298298
const updatePosition = function() {
299+
// Find existing tooltips for the same element to calculate inline positioning
300+
const existingTooltips = Array.from( document.querySelectorAll( '.edac-highlight-btn' ) ).filter( ( btn ) => {
301+
// Check if this tooltip targets the same element by comparing their positioning reference
302+
return btn !== tooltip && btn.dataset.targetElement === element.outerHTML.replace( /\W/g, '' );
303+
} );
304+
305+
const tooltipOffset = existingTooltips.length;
306+
299307
computePosition( element, tooltip, {
300308
placement: 'top-start',
301309
middleware: [],
@@ -307,7 +315,7 @@ class AccessibilityCheckerHighlight {
307315
const tooltipWidth = tooltip.offsetWidth === undefined ? 0 : tooltip.offsetWidth;
308316

309317
let top = 0;
310-
const left = 0;
318+
const left = tooltipOffset * ( tooltipWidth + 5 ); // 5px gap between buttons
311319

312320
if ( tooltipHeight <= ( elHeight * .8 ) ) {
313321
top = tooltipHeight;
@@ -336,6 +344,9 @@ class AccessibilityCheckerHighlight {
336344
} );
337345
};
338346

347+
// Store reference to target element for positioning calculations
348+
tooltip.dataset.targetElement = element.outerHTML.replace( /\W/g, '' );
349+
339350
// Place the tooltip at the element's position on the page.
340351
// See: https://floating-ui.com/docs/autoUpdate
341352
const cleanup = autoUpdate(

0 commit comments

Comments
 (0)