Repository navigation
Hush's own small controls can be reached with Tab and pressed with Return or Space, and every dialog keeps Tab and takes Esc - #284
Merged
Conversation
A shared pressable() gives a small control a Tab stop, the theme's focus ring while it has the keys, and Return/Space to press it; a click leaves the keys where they were. Notice actions, reaction pills and picker, poll options, swatches, stickers, the banner's close, file downloads and the rest of the click-only controls use it. The view-once look keeps Tab inside, and Esc in the history transfer is Continue Without History.
…ps them, rings have room A pressable takes no focus from any mouse button, so a right-click's menu hands the keys back to the composer. A file's control stays a tab stop while it downloads and decodes. Archived Chats is the row inside the list's margin, and the sticker picker's tabs and grid leave room for the ring. Tests: a click and a right-click keep the composer's keys, a download keeps the keys, the view-once trap holds Close for the photo and the video. One said() helper.
Owner
Author
Review (
|
…er failed While the transfer waits for the phone or runs, Esc does nothing, so a stray key doesn't give the history up; after a failure Esc is Continue Without History, as the button there.
Owner
Author
|
Owner's decision applied in 5bcb39c: Esc on the history transfer works only once the transfer has failed (Continue Without History, as the button there); while it waits for the phone or runs, Esc does nothing and the history is kept. Test first: |
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.
What changed
pressable()(app/view.rs), one way for a control of Hush's own to take the keys, the way gpui-component's buttons do: it gives the control a focus handle that is a Tab stop, the theme's focus ring (gpui-component'sfocus_ring_style, the ring its own buttons and fields draw) while the control has the keys, and a mouse-down that leaves the keys where they were (as gpui-component'sButtondoes), so a click doesn't take the keys from the composer. GPUI already presses a focused element with a click listener when Return or Space is let go.PressableforwardsInteractiveElement/Styled/ParentElement, so a call site only wraps itsdiv().id(…)and keeps its chain (its click, a context menu, a popover's trigger).focus_traparound the photo and its Close, and around the video's card); the history transfer takes Esc as Continue Without History once it has failed, and ignores it while it waits or runs, so a stray Esc doesn't give the history up (owner's decision; it already trapped Tab).Trigger(a popover's trigger in our own look) takes any element.--snapshotgainsfocused: the chat colour picker with its first swatch reached by Tab.Left as they are, each already reachable another way: the chat list's rows and the search's hits (⌥↑↓, ⌘1–9, the arrows in the search), the mention picker's rows (↑↓ and Return in the composer), the stories' chat list (↑↓ in the stories window), and the Send button (Return).
Not done: a message's hover buttons (React, Reply, More) show under the pointer only, and GPUI doesn't lay out a hidden element's Tab stops, so the keyboard still can't reach them, nor the message menu they open. The picker's reactions take the keys once it's open. Reaching them needs a choice for the owner (see below).
Why
Found while writing DESIGN.md (#267): about 20 of Hush's own small controls took a click only, and two dialogs didn't keep Tab or take Esc.
How it was tested
Window tests, one per kind of control, each written first and failing on the base (
Tab never reaches …,Tab stays in the look,the core was asked to end the transfer), passing after:view::the_error_banners_close_is_pressed_from_the_keyboard(Return)events::a_notices_action_is_pressed_from_the_keyboard(Space: the safety number shows)actions::a_reaction_pill_opens_who_reacted_from_the_keyboard(Return)actions::the_pickers_reaction_is_pressed_from_the_keyboard(Space: the picker closes)polls::a_polls_option_is_voted_for_from_the_keyboard(Return: the vote reaches the core)options::a_swatch_is_chosen_from_the_keyboard(Return: the change reaches the core)stickers::a_sticker_is_sent_from_the_keyboard(Return: the picker closes)files::a_files_download_is_pressed_from_the_keyboard(Return, on the photo and on the failed file: the download reaches the core)view_once::tab_stays_in_the_look_close_included(photo and video: Tab stays in, and Return on Close closes it)view::esc_continues_without_the_history_only_once_the_transfer_failed(Esc while waiting or downloading asks the core nothing; after a failure the core reportsNoHistory)Added in review, each failing on the code before its fix:
files::a_click_on_a_file_presses_it_and_leaves_the_keys_in_the_composer(a click still presses; a click or a right-click and Esc leave the composer the keys)files::a_download_pressed_from_the_keyboard_keeps_the_keys_while_it_comesThe tests find the focused control by a
focused <id>debug selector the ring sets (recorded only in debug builds withsnapshot, as the app's other debug selectors).make format && make checkon the branch merged withorigin/main(at f1051bd, after review and the owner's Esc decision):cargo fmt --checkpass;cargo clippy --all-targets -D warningspass, and with--features hush-desktop/snapshotpass;cargo test --features hush-desktop/snapshotpass (376 + 546 tests, 4 ignored as before).Snapshots (
cargo run -p hush-desktop --features snapshot -- --snapshot <dir>), looked at:focused-light/focused-dark(the first swatch with the theme's ring, the same ring gpui-component's buttons draw),sticker-picker(four to a row still, with room for the ring),files(the photos keep their size, corners and clip after the clip moved inside),story-video(the card keeps its corners unclipped),chat-style,events,polls,stickers,reply.For the owner
Closes #272