fix close modal
This commit is contained in:
@@ -10,11 +10,6 @@ import (
|
||||
type KeyMap struct {
|
||||
components.CommonKeyMap
|
||||
SwitchToKanbanBoard key.Binding
|
||||
Quit key.Binding
|
||||
SelectIssue key.Binding
|
||||
BackToList key.Binding
|
||||
ScrollUp key.Binding
|
||||
ScrollDown key.Binding
|
||||
EditTitle key.Binding
|
||||
EditDescription key.Binding
|
||||
ChangeStatus key.Binding
|
||||
@@ -78,8 +73,8 @@ func (m *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
||||
m.logAction("tui toggled help")
|
||||
|
||||
case m.notInModalMsgWithKey(msg, m.keyMap.Quit):
|
||||
m.logAction("tui quit requested")
|
||||
return tea.Quit
|
||||
m.logAction("tui opened exit confirmation")
|
||||
return m.startConfirmExit()
|
||||
|
||||
case m.notInModalMsgWithKey(msg, m.keyMap.SwitchToKanbanBoard):
|
||||
return func() tea.Msg { return msgs.SwitchToKanbanBoardMsg{} }
|
||||
|
||||
@@ -34,6 +34,10 @@ func (m *Model) refreshAndSubmit(issueID string) tea.Cmd {
|
||||
return refreshCmd
|
||||
}
|
||||
|
||||
func (m *Model) startConfirmExit() tea.Cmd {
|
||||
return m.modalManager.ShowModal(modal.ModalConfirmExit)
|
||||
}
|
||||
|
||||
func (m *Model) startEditTitle(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
titleModal := m.modalManager.GetTextInputModal(modal.ModalEditTitle)
|
||||
@@ -113,6 +117,11 @@ func (m *Model) startAddComment(selected ListIssue) tea.Cmd {
|
||||
// handleModalCompleted handles all modal completion messages
|
||||
func (m *Model) handleModalCompleted(msg modal.ModalCompletedMsg) tea.Cmd {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalConfirmExit:
|
||||
if r, ok := msg.Value.(modal.ConfirmResult); ok && r.Confirmed {
|
||||
m.logAction("tui confirmed exit")
|
||||
return tea.Quit
|
||||
}
|
||||
case modal.ModalEditTitle:
|
||||
if r, ok := msg.Value.(modal.TextInputResult); ok {
|
||||
m.logAction("tui submitted issue title edit")
|
||||
@@ -196,6 +205,8 @@ func (m *Model) handleModalCompleted(msg modal.ModalCompletedMsg) tea.Cmd {
|
||||
// handleModalCancelled handles all modal cancellation messages
|
||||
func (m *Model) handleModalCancelled(msg modal.ModalCancelledMsg) {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalConfirmExit:
|
||||
m.logAction("tui canceled exit")
|
||||
case modal.ModalEditTitle:
|
||||
m.currentIssueID = ""
|
||||
m.logAction("tui canceled issue title edit")
|
||||
@@ -354,6 +365,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
return m, m.refreshIssueListsAndSelectIssue(msg.IssueID)
|
||||
|
||||
case tea.KeyPressMsg:
|
||||
if msg.String() == "ctrl+c" {
|
||||
return m, tea.Quit
|
||||
}
|
||||
|
||||
if m.issueList.FilterState() == list.Filtering {
|
||||
cmd, _ := m.issueList.Update(msg)
|
||||
return m, cmd
|
||||
@@ -364,7 +379,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
cmd := m.handleKeyPressMsg(msg)
|
||||
if cmd != nil {
|
||||
if cmd != nil || m.IsInModal() {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ func (m *Model) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
|
||||
m.helpBar.ToggleHelp()
|
||||
|
||||
case m.notInModalMsgWithKey(msg, m.keyMap.Quit):
|
||||
return tea.Quit
|
||||
m.logAction("tui opened exit confirmation")
|
||||
return m.startConfirmExit()
|
||||
|
||||
case m.notInModalMsgWithKey(msg, m.keyMap.SwitchToDashboard):
|
||||
return func() tea.Msg { return msgs.SwitchToDashboardMsg{} }
|
||||
|
||||
@@ -62,6 +62,10 @@ func (m *Model) refreshAndSubmit(issueID string) tea.Cmd {
|
||||
|
||||
// Modal action handlers
|
||||
|
||||
func (m *Model) startConfirmExit() tea.Cmd {
|
||||
return m.modalManager.ShowModal(modal.ModalConfirmExit)
|
||||
}
|
||||
|
||||
func (m *Model) startEditTitle(selected ListIssue) tea.Cmd {
|
||||
m.currentIssueID = selected.ID
|
||||
titleModal := m.modalManager.GetTextInputModal(modal.ModalEditTitle)
|
||||
@@ -141,6 +145,11 @@ func (m *Model) startAddComment(selected ListIssue) tea.Cmd {
|
||||
// handleModalCompleted handles all modal completion messages
|
||||
func (m *Model) handleModalCompleted(msg modal.ModalCompletedMsg) tea.Cmd {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalConfirmExit:
|
||||
if r, ok := msg.Value.(modal.ConfirmResult); ok && r.Confirmed {
|
||||
m.logAction("tui confirmed exit")
|
||||
return tea.Quit
|
||||
}
|
||||
case modal.ModalEditTitle:
|
||||
if r, ok := msg.Value.(modal.TextInputResult); ok {
|
||||
cmd := msgs.UpdateIssueTitleCmd(m.app, m.currentIssueID, r.Value)
|
||||
@@ -218,6 +227,8 @@ func (m *Model) handleModalCompleted(msg modal.ModalCompletedMsg) tea.Cmd {
|
||||
// handleModalCancelled handles all modal cancellation messages
|
||||
func (m *Model) handleModalCancelled(msg modal.ModalCancelledMsg) {
|
||||
switch msg.ModalID {
|
||||
case modal.ModalConfirmExit:
|
||||
m.logAction("tui canceled exit")
|
||||
case modal.ModalEditTitle:
|
||||
m.currentIssueID = ""
|
||||
case modal.ModalCreateIssue:
|
||||
@@ -458,6 +469,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
})
|
||||
|
||||
case tea.KeyPressMsg:
|
||||
if msg.String() == "ctrl+c" {
|
||||
return m, tea.Quit
|
||||
}
|
||||
|
||||
fl := m.FocusedIssueList()
|
||||
if fl.FilterState() == list.Filtering {
|
||||
cmd, _ := fl.Update(msg)
|
||||
@@ -469,7 +484,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
cmd := m.handleKeyPressMsg(msg)
|
||||
if cmd != nil {
|
||||
if cmd != nil || m.IsInModal() {
|
||||
return m, cmd
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user