ui: let Enter submit the field-based dialogs
CI / test (push) Successful in 1m18s

The AdwAlertDialog forms put their field in extra-child and relied on
set_default_response alone, but a GtkText/GtkEntry consumes Return unless
activates-default is set — so the default action was reachable only with the
pointer. Opt in on unlock, export, change passphrase and both rename dialogs,
and record the trap in AGENTS.md.
This commit is contained in:
raucao committed 2026-12-01 11:12:38 +04:00
1 parent b2519f6214
commit 60d80a7591
6 files changed
+34

No files matched your search

+13
View File
@@ -1238,6 +1238,19 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
ignored too). A plain `AdwDialog` *does* honour it, which is why "Connect an
app" worked. Set `width-request` instead (`plain::alert_width`), which the
dialog honours exactly. Do not "simplify" it back to `content_width`.
18. **A field in a dialog swallows Return unless it opts in.** The `GtkText`
inside every `AdwEntryRow` (and inside `GtkEntry`) has its own Return
binding: it emits `activate` and consumes the event, and only calls
`gtk_widget_activate_default()` when `activates-default` is `TRUE` — which
defaults to `FALSE`. So a dialog whose `extra-child` field should submit on
Enter needs `set_activates_default(true)` on that field;
`set_default_response`/`AdwDialog:default-widget` alone do nothing while the
field has focus, and focus starts there (`adw_alert_dialog_grab_focus`
prefers the extra child). Symptom: the user types, presses Enter, nothing
happens. The `FormDialog` forms (`ui/keys_view.rs`) opt in on every row; the
`AdwAlertDialog` forms (unlock, rename identity/app, export, change
passphrase) must too — and do not add live validation to them to compensate,
the alert dialog has none.
## Blueprint / Meson traps
+6
View File
@@ -13,6 +13,12 @@ the only place release notes are written.
## [Unreleased]
### Fixed
- Enter now submits the field-based dialogs — unlock, export, change passphrase,
rename identity and rename application. Their fields consumed the key, so the
dialog's default action could only be reached with the pointer.
## [0.9.1] - 2026-11-30
### Fixed
+3
View File
@@ -451,6 +451,9 @@ async fn ask_passphrase(
deadline: Option<Instant>,
) -> Option<Zeroizing<String>> {
let entry = adw::PasswordEntryRow::builder().title("Passphrase").build();
// Enter in the field submits, as the HIG asks of an action dialog: the field
// would otherwise swallow Return and the default response would never fire.
entry.set_activates_default(true);
let list = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
.css_classes(["boxed-list"])
+2
View File
@@ -414,6 +414,8 @@ impl Ui {
let entry = gtk::Entry::builder()
.text(app.display_name().unwrap_or_default())
.build();
// Enter in the field activates the default response ("Save").
entry.set_activates_default(true);
let dialog = adw::AlertDialog::builder()
.heading("Name application")
.body("Only you see this name; what the application declared is not changed.")
+6
View File
@@ -1031,6 +1031,9 @@ fn with_unlocked<F: FnOnce() + 'static>(handles: &Handles, state: &Rc<AppState>,
fn present_rename(handles: Handles, state: Rc<AppState>, public_key: PublicKey, current: &str) {
let entry = gtk::Entry::builder().text(current).build();
// Enter in the field activates the default response ("Rename"); a `GtkEntry`
// swallows Return otherwise.
entry.set_activates_default(true);
let dialog = adw::AlertDialog::builder()
.heading("Rename identity key")
.extra_child(&entry)
@@ -1079,6 +1082,9 @@ fn present_export_dialog(handles: Handles, state: Rc<AppState>, public_key: Publ
// Confirmed and ≥8 characters: an accidental empty submit must not encrypt
// the key under `""`, and a typo must not produce an unrecoverable backup.
let fields = PassphraseFields::export();
// Enter submits: the export form is an `AdwAlertDialog` with a default
// response, and the rows must opt in or they swallow Return.
fields.set_activates_default();
let list = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
.css_classes(["boxed-list"])
+4
View File
@@ -490,6 +490,10 @@ impl Preferences {
let confirm = adw::PasswordEntryRow::builder()
.title("Confirm passphrase")
.build();
// Enter submits: an `AdwAlertDialog` field must opt in or it swallows
// Return, and the "Change" response would never fire.
new.set_activates_default(true);
confirm.set_activates_default(true);
let list = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
.css_classes(["boxed-list"])