Skip to content
Merged
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
17 changes: 12 additions & 5 deletions accessibility/keyboardui.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,21 @@ const GizmoMenuManager = {
renderBadges() {
const container = document.getElementById('gizmo-menu-content');
container.innerHTML = '';
this.buttons.forEach((entry) => {
const el = document.getElementById(entry.id);
if (!el || el.offsetParent === null) return;
const rect = el.getBoundingClientRect();
const visible = this.buttons
.map((entry) => {
const el = document.getElementById(entry.id);
if (!el || el.offsetParent === null) return null;
return { entry, rect: el.getBoundingClientRect() };
})
.filter(Boolean);
// If badges span two rows, put top row badges on top
const bottomRowTop = Math.max(...visible.map(({ rect }) => rect.top));
visible.forEach(({ entry, rect }) => {
const badge = document.createElement('div');
badge.className = 'gizmo-key-badge';
badge.innerText = entry.label;
badge.style.top = `${rect.top + rect.height + 8}px`;
const isBottomRow = rect.top >= bottomRowTop - rect.height / 2;
badge.style.top = isBottomRow ? `${rect.top + rect.height + 8}px` : `${rect.top - 8}px`;
badge.style.left = `${rect.left + rect.width / 2}px`;
container.appendChild(badge);
});
Expand Down
Loading