]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-138122: Tachyon heatmap: Make toggle switches keyboard accessible (#142601)
authorStan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Thu, 11 Dec 2025 21:58:09 +0000 (21:58 +0000)
committerGitHub <noreply@github.com>
Thu, 11 Dec 2025 21:58:09 +0000 (21:58 +0000)
Lib/profiling/sampling/_heatmap_assets/heatmap.css
Lib/profiling/sampling/_heatmap_assets/heatmap.js
Lib/profiling/sampling/_heatmap_assets/heatmap_pyfile_template.html
Lib/profiling/sampling/_shared_assets/base.css

index b5aa828c99c3e08ab259446375c5059e762f8490..dfb6fd69b40ee651c5f67d506e3dddd7eb38bcb9 100644 (file)
   opacity: 0.85;
 }
 
+.toggle-switch:focus-visible {
+  border-radius: 4px;
+}
+
 .toggle-switch .toggle-label {
   font-size: 11px;
   font-weight: 500;
index 9cedb2d84698b6608934e35ca514e3b6107322d2..038aa44b3df6192f977fcfca599b768163bc0edd 100644 (file)
@@ -733,7 +733,7 @@ function toggleAllBytecode() {
     }
 }
 
-// Keyboard shortcut: 'b' toggles all bytecode panels
+// Keyboard shortcut: 'b' toggles all bytecode panels, Enter/Space activates toggle switches
 document.addEventListener('keydown', function(e) {
     if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') {
         return;
@@ -741,6 +741,10 @@ document.addEventListener('keydown', function(e) {
     if (e.key === 'b' && !e.ctrlKey && !e.altKey && !e.metaKey) {
         toggleAllBytecode();
     }
+    if ((e.key === 'Enter' || e.key === ' ') && e.target.classList.contains('toggle-switch')) {
+        e.preventDefault();
+        e.target.click();
+    }
 });
 
 // Handle hash changes
index 3d857c49d27962be0f73d03460b0559c91104ad5..3fb6d3a6b91dbb25bb90c3a27af27733b3ab4f3e 100644 (file)
                 </div>
                 <div class="legend-separator" aria-hidden="true"></div>
                 <div class="legend-controls">
-                    <div class="toggle-switch" id="toggle-color-mode" title="Toggle between self time and total time coloring">
+                    <div class="toggle-switch" id="toggle-color-mode" title="Toggle between self time and total time coloring" tabindex="0">
                         <span class="toggle-label active" data-text="Self Time">Self Time</span>
                         <div class="toggle-track"></div>
                         <span class="toggle-label" data-text="Total Time">Total Time</span>
                     </div>
-                    <div class="toggle-switch" id="toggle-cold" title="Toggle visibility of lines with zero samples">
+                    <div class="toggle-switch" id="toggle-cold" title="Toggle visibility of lines with zero samples" tabindex="0">
                         <span class="toggle-label active" data-text="Show All">Show All</span>
                         <div class="toggle-track"></div>
                         <span class="toggle-label" data-text="Hot Only">Hot Only</span>
                     </div>
-                    <div class="toggle-switch" id="toggle-spec-view" title="Color lines by specialization level (requires bytecode data)">
+                    <div class="toggle-switch" id="toggle-spec-view" title="Color lines by specialization level (requires bytecode data)" tabindex="0">
                         <span class="toggle-label active" data-text="Heat">Heat</span>
                         <div class="toggle-track"></div>
                         <span class="toggle-label" data-text="Specialization">Specialization</span>
index 46916709f19f549ed31f75cb365929d997ada446..c88cf58eef9260c5cf183403a4567d7479e644f4 100644 (file)
@@ -387,6 +387,7 @@ body {
 button:focus-visible,
 select:focus-visible,
 input:focus-visible,
+.toggle-switch:focus-visible,
 a.toolbar-btn:focus-visible {
   outline: 2px solid var(--python-gold);
   outline-offset: 2px;