Repository navigation
fix: don't make disabled axis areas keyboard-focusable - #269
Merged
lucasmerlin merged 2 commits intoOct 19, 2026
Merged
Conversation
|
View snapshot changes at kitdiff |
TssHack
marked this pull request as ready for review
October 13, 2026 05:38
lucasmerlin
approved these changes
Oct 19, 2026
lucasmerlin
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! I've changed it so the axis can never have focus, since focus useless there anyways
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
allocate_axis_responsesallocated every axis rect withSense::drag()regardless ofallow_axis_zoom_drag.Sense::drag()isDRAG | FOCUSABLE, and egui gives focus interestand an AccessKit node to any focusable widget. A static, display-only plot therefore added
two unnamed, inert Tab stops, one per axis. The only way to remove them was
show_axes(false), which also removes the axes.Reported in #268. I confirmed the mechanism in the pinned egui revision, where
Sense::hover()isSelf::empty()and therefore not focusable.Change
Pick the sense per axis instead of globally:
used as
axis_sense(0)/axis_sense(1). Disabling zoom-drag on one axis leaves the otheraxis draggable and focusable.
Sense::hover()still participates in hit-testing, so the hover cursor and rect allocationare unchanged. The drag-to-zoom handler was already guarded by
allow_axis_zoom_drag, sodrag behaviour is unchanged. This also documents the new contract on
Plot::allow_axis_zoom_drag.Scope: one function, no API change, no breaking change.
Tests
Four
egui_kittesttests in the existingplot_testsmodule. The axis areas carry noaccessible name, so they are distinguished by AccessKit bounding-box shape: an x axis is the
wide, short strip along the bottom, a y axis the narrow, tall strip along the left.
Assertions are sorted, so they do not depend on AccessKit traversal order, and no
coordinates are hard-coded.
disabled_axes_are_not_focusable-- all interactions off: only the following button is focusable.enabled_axes_are_focusable-- both axes on: button plus both axis areas are focusable.mixed_axes_are_focusable_per_axis--[true, false]keeps only the x axis;[false, true]keeps only the y axis.mixed_axes_are_focusable_at_other_sizes-- the per-axis expectations hold at three other UI sizes.I checked that the tests actually catch regressions: with both axes wrongly gated on a single
flag (in either direction),
mixed_axes_are_focusable_per_axisandmixed_axes_are_focusable_at_other_sizesfail; with the fix they pass.The axis shape discrimination was measured rather than assumed: across 153 width/height
combinations the smallest x-axis aspect ratio observed was 2.54 and the largest y-axis aspect
ratio was 0.31, so the "wider than tall" test has a wide margin and does not depend on fonts
or exact pixel sizes.
Validation performed
cargo test -p egui_plot-- 9 passed, 0 failed; doctests 4 passed, 2 ignoredcargo clippy -p egui_plot --all-targets --all-features -- -D warnings-- cleancargo fmt --all -- --check-- cleancargo check --workspace --all-targets-- cleangit diff --check-- cleanNot run:
./scripts/check.sh(it installstypos-cliand runscargo deny, which neednetwork access). Opening as a draft per CONTRIBUTING.md until that has been run.
Disclosure
An AI coding assistant was used to investigate the issue, implement the change, and write the
tests. I reviewed the diff and ran the validation listed above.
Notes for reviewers
24c7dd760b75253953642d0d357e30a6458a5739fix/disabled-axis-keyboard-focus, based onmainata9d6c96egui_plot/src/plot.rs(+150/-3)