Skip to content

Commit 40ac3a9

Browse files
gh-138122: Tachyon Flamegraph: Make toggle keyboard accesible and adjust sidebar collapse CSS (#142638)
1 parent 6d644e4 commit 40ac3a9

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

Lib/profiling/sampling/_flamegraph_assets/flamegraph.css

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,8 @@ body.resizing-sidebar {
275275
}
276276

277277
/* View Mode Section */
278-
.view-mode-section {
279-
padding-bottom: 20px;
280-
border-bottom: 1px solid var(--border);
281-
}
282-
283-
.view-mode-section .section-title {
284-
margin-bottom: 12px;
285-
}
286-
287-
.view-mode-section .toggle-switch {
278+
.view-mode-section .section-content {
279+
display: flex;
288280
justify-content: center;
289281
}
290282

@@ -316,15 +308,17 @@ body.resizing-sidebar {
316308
}
317309

318310
.section-content {
319-
transition: max-height var(--transition-normal), opacity var(--transition-normal);
311+
transition: max-height var(--transition-slow) ease-out, opacity var(--transition-normal) ease-out, padding var(--transition-normal) ease-out;
320312
max-height: 1000px;
321313
opacity: 1;
322314
}
323315

324316
.collapsible.collapsed .section-content {
325317
max-height: 0;
326318
opacity: 0;
327-
margin-bottom: -10px;
319+
padding-top: 0;
320+
pointer-events: none;
321+
transition: max-height var(--transition-slow) ease-in, opacity var(--transition-normal) ease-in, padding var(--transition-normal) ease-in;
328322
}
329323

330324
/* --------------------------------------------------------------------------
@@ -634,10 +628,6 @@ body.resizing-sidebar {
634628
Legend
635629
-------------------------------------------------------------------------- */
636630

637-
.legend-section {
638-
margin-top: auto;
639-
padding-top: 12px;
640-
}
641631

642632
.legend {
643633
display: flex;
@@ -1023,3 +1013,7 @@ body.resizing-sidebar {
10231013
border-color: #8e44ad;
10241014
box-shadow: 0 0 8px rgba(142, 68, 173, 0.3);
10251015
}
1016+
1017+
.toggle-switch:focus-visible {
1018+
border-radius: 4px;
1019+
}

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: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,19 @@
102102
</div>
103103

104104
<!-- View Mode Section -->
105-
<section class="sidebar-section view-mode-section">
106-
<h3 class="section-title">View Mode</h3>
107-
<div class="toggle-switch" id="toggle-invert">
108-
<span class="toggle-label active">Flamegraph</span>
109-
<div class="toggle-track"></div>
110-
<span class="toggle-label">Inverted Flamegraph</span>
105+
<section class="sidebar-section view-mode-section collapsible" id="view-mode-section">
106+
<button class="section-header" onclick="toggleSection('view-mode-section')">
107+
<h3 class="section-title">View Mode</h3>
108+
<svg class="section-chevron" width="12" height="12" viewBox="0 0 12 12" fill="none">
109+
<path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
110+
</svg>
111+
</button>
112+
<div class="section-content">
113+
<div class="toggle-switch" id="toggle-invert" title="Toggle between standard and inverted flamegraph view" tabindex="0">
114+
<span class="toggle-label active" data-text="Flamegraph">Flamegraph</span>
115+
<div class="toggle-track"></div>
116+
<span class="toggle-label" data-text="Inverted Flamegraph">Inverted Flamegraph</span>
117+
</div>
111118
</div>
112119
</section>
113120

Lib/profiling/sampling/_shared_assets/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
/* Transitions */
3838
--transition-fast: 0.15s ease;
3939
--transition-normal: 0.25s ease;
40+
--transition-slow: 0.3s ease;
4041
}
4142

4243
/* Light theme (default) */

0 commit comments

Comments
 (0)