mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-12 07:41:42 +00:00
fix(ui): Esc cancels delete confirmation instead of confirming it
In the remove-wizard's confirming state, pressing Esc was reflexively calling removeForwardsCmd — i.e. confirming deletion. The on-screen help text said 'Esc: Cancel'. Reflexive Esc-to-cancel destroyed data. Esc now sets confirming=false and resets the cursor; deletion requires Enter on Yes. Non-confirming Esc behavior (exit wizard with ClearScreen) is unchanged. Three regression tests added in handlers_test.go.
This commit is contained in:
@@ -722,14 +722,15 @@ func (m model) handleRemoveWizardKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
|
||||
case "esc":
|
||||
if wizard.confirming {
|
||||
// In confirmation mode, Esc confirms the removal (same as pressing Yes)
|
||||
selectedForwards := wizard.getSelectedForwards()
|
||||
return m, removeForwardsCmd(m.ui.mutator, selectedForwards)
|
||||
} else {
|
||||
// Not confirming yet - cancel entirely
|
||||
m.ui.viewMode = ViewModeMain
|
||||
m.ui.removeWizard = nil
|
||||
// In confirmation mode, Esc cancels the confirmation (matches help text "Esc: Cancel")
|
||||
// Returns to selection state without dispatching removal.
|
||||
wizard.confirming = false
|
||||
wizard.confirmCursor = 0
|
||||
return m, nil
|
||||
}
|
||||
// Not confirming yet - cancel entirely
|
||||
m.ui.viewMode = ViewModeMain
|
||||
m.ui.removeWizard = nil
|
||||
return m, tea.ClearScreen
|
||||
|
||||
case "up", "k":
|
||||
|
||||
Reference in New Issue
Block a user