Skip to content

Commit f00e637

Browse files
Make flamegraph invert toggle keyboard accessible, add title and stop the toggle moving when swicted
1 parent 340a684 commit f00e637

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Lib/profiling/sampling/_flamegraph_assets/flamegraph.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,3 +1023,7 @@ body.resizing-sidebar {
10231023
border-color: #8e44ad;
10241024
box-shadow: 0 0 8px rgba(142, 68, 173, 0.3);
10251025
}
1026+
1027+
.toggle-switch:focus-visible {
1028+
border-radius: 4px;
1029+
}

Lib/profiling/sampling/_flamegraph_assets/flamegraph.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,17 @@ function initFlamegraph() {
13021302
}
13031303
}
13041304

1305+
// Keyboard shortcut: Enter/Space activates toggle switches
1306+
document.addEventListener('keydown', function(e) {
1307+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
1308+
return;
1309+
}
1310+
if ((e.key === 'Enter' || e.key === ' ') && e.target.classList.contains('toggle-switch')) {
1311+
e.preventDefault();
1312+
e.target.click();
1313+
}
1314+
});
1315+
13051316
if (document.readyState === "loading") {
13061317
document.addEventListener("DOMContentLoaded", initFlamegraph);
13071318
} else {

Lib/profiling/sampling/_flamegraph_assets/flamegraph_template.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@
104104
<!-- View Mode Section -->
105105
<section class="sidebar-section view-mode-section">
106106
<h3 class="section-title">View Mode</h3>
107-
<div class="toggle-switch" id="toggle-invert">
108-
<span class="toggle-label active">Flamegraph</span>
107+
<div class="toggle-switch" id="toggle-invert" title="Toggle between standard and inverted flamegraph view" tabindex="0">
108+
<span class="toggle-label active" data-text="Flamegraph">Flamegraph</span>
109109
<div class="toggle-track"></div>
110-
<span class="toggle-label">Inverted Flamegraph</span>
110+
<span class="toggle-label" data-text="Inverted Flamegraph">Inverted Flamegraph</span>
111111
</div>
112112
</section>
113113

0 commit comments

Comments
 (0)