Fix #5307 #5037 : 列表点击后无法 esc 返回#5311
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes issues where, after clicking into certain list views, pressing Esc no longer triggers the global “back” navigation handler.
Changes:
- Disables focus traversal on the resourcepack list
JFXListView. - Disables focus traversal on all
JFXListViewinstances created byToolbarListPageSkin.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcepackListPage.java |
Prevents the resourcepack list from becoming focus-traversable to avoid consuming Esc/back. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/ToolbarListPageSkin.java |
Applies the same focus-traversable change to all list pages using the shared skin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| center.getStyleClass().add("large-spinner-pane"); | ||
| center.loadingProperty().bind(control.loadingProperty()); | ||
|
|
||
| listView.setFocusTraversable(false); |
There was a problem hiding this comment.
Setting the ListView to non-focus-traversable is a very broad fix for the ESC/back issue and can regress keyboard interaction (arrow-key navigation, type-to-select, accessibility focus). In other list pages (e.g., versions/ModListPageSkin.java and versions/DatapackListPageSkin.java) the pattern is to bypass ListViewBehavior only for ESC via FXUtils.ignoreEvent(listView, KeyEvent.KEY_PRESSED, e -> e.getCode() == KeyCode.ESCAPE) so ESC can reach the global handler without disabling focus entirely. Consider switching to that approach here instead of setFocusTraversable(false).
| this.listView.setPadding(Insets.EMPTY); | ||
| this.listView.setFocusTraversable(false); | ||
| this.listView.setCellFactory(listView -> createListCell((JFXListView<E>) listView)); |
There was a problem hiding this comment.
listView.setFocusTraversable(false) changes focus behavior for every page using ToolbarListPageSkin (Java management, installer list, world list, etc.) and can break keyboard navigation/selection in these lists. The underlying ESC/back problem is typically handled more narrowly by letting ESC bypass the ListView dispatcher (see FXUtils.ignoreEvent(...) usage in versions/ModListPageSkin.java / versions/DatapackListPageSkin.java). Consider replacing this with an ESC-specific FXUtils.ignoreEvent(listView, KeyEvent.KEY_PRESSED, e -> e.getCode() == KeyCode.ESCAPE) so ESC reaches DecoratorController’s global handler while preserving normal focus/keyboard behavior.
|
这样改是不是会进一步破坏用键盘控制时的体验? |
No description provided.