on main help sign in
fix: route mouse events to the dialog if its showing (#1953)
1382753Kujtim Hoxha
internal/ui/model/ui.go+16
@@ -497,6 +497,11 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
497 case copyChatHighlightMsg:
497 case copyChatHighlightMsg:
498 cmds = append(cmds, m.copyChatHighlight())
498 cmds = append(cmds, m.copyChatHighlight())
499 case tea.MouseClickMsg:
499 case tea.MouseClickMsg:
500+ // Pass mouse events to dialogs first if any are open.
501+ if m.dialog.HasDialogs() {
502+ m.dialog.Update(msg)
503+ return m, tea.Batch(cmds...)
504+ }
500 switch m.state {
505 switch m.state {
501 case uiChat:
506 case uiChat:
502 x, y := msg.X, msg.Y
507 x, y := msg.X, msg.Y
@@ -509,6 +514,12 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
509 }
514 }
510
515
511 case tea.MouseMotionMsg:
516 case tea.MouseMotionMsg:
517+ // Pass mouse events to dialogs first if any are open.
518+ if m.dialog.HasDialogs() {
519+ m.dialog.Update(msg)
520+ return m, tea.Batch(cmds...)
521+ }
522+
512 switch m.state {
523 switch m.state {
513 case uiChat:
524 case uiChat:
514 if msg.Y <= 0 {
525 if msg.Y <= 0 {
@@ -541,6 +552,11 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
541 }
552 }
542
553
543 case tea.MouseReleaseMsg:
554 case tea.MouseReleaseMsg:
555+ // Pass mouse events to dialogs first if any are open.
556+ if m.dialog.HasDialogs() {
557+ m.dialog.Update(msg)
558+ return m, tea.Batch(cmds...)
559+ }
544 const doubleClickThreshold = 500 * time.Millisecond
560 const doubleClickThreshold = 500 * time.Millisecond
545
561
546 switch m.state {
562 switch m.state {