on main help sign in
feat(diffview): only process scroll events when pointer is over dialog
fb6dab0Andrey Nering
internal/tui/components/dialogs/permissions/permissions.go+21−2
@@ -64,6 +64,8 @@ type permissionDialogCmp struct {
64 positionRow int // Row position for dialog
64 positionRow int // Row position for dialog
65 positionCol int // Column position for dialog
65 positionCol int // Column position for dialog
66
66
67+ finalDialogHeight int
68+
67 keyMap KeyMap
69 keyMap KeyMap
68}
70}
69
71
@@ -159,7 +161,7 @@ func (p *permissionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
159 cmds = append(cmds, cmd)
161 cmds = append(cmds, cmd)
160 }
162 }
161 case tea.MouseWheelMsg:
163 case tea.MouseWheelMsg:
162− if p.supportsDiffView() {
164+ if p.supportsDiffView() && p.isMouseOverDialog(msg.Mouse().X, msg.Mouse().Y) {
163 switch msg.Button {
165 switch msg.Button {
164 case tea.MouseWheelDown:
166 case tea.MouseWheelDown:
165 p.scrollDown()
167 p.scrollDown()
@@ -196,6 +198,21 @@ func (p *permissionDialogCmp) scrollRight() {
196 p.contentDirty = true
198 p.contentDirty = true
197}
199}
198
200
201+// isMouseOverDialog checks if the given mouse coordinates are within the dialog bounds.
202+// Returns true if the mouse is over the dialog area, false otherwise.
203+func (p *permissionDialogCmp) isMouseOverDialog(x, y int) bool {
204+ if p.permission.ID == "" {
205+ return false
206+ }
207+ var (
208+ dialogX = p.positionCol
209+ dialogY = p.positionRow
210+ dialogWidth = p.width
211+ dialogHeight = p.finalDialogHeight
212+ )
213+ return x >= dialogX && x < dialogX+dialogWidth && y >= dialogY && y < dialogY+dialogHeight
214+}
215+
199func (p *permissionDialogCmp) selectCurrentOption() tea.Cmd {
216func (p *permissionDialogCmp) selectCurrentOption() tea.Cmd {
200 var action PermissionAction
217 var action PermissionAction
201
218
@@ -683,7 +700,7 @@ func (p *permissionDialogCmp) render() string {
683 }
700 }
684 content := lipgloss.JoinVertical(lipgloss.Top, strs...)
701 content := lipgloss.JoinVertical(lipgloss.Top, strs...)
685
702
686− return baseStyle.
703+ dialog := baseStyle.
687 Padding(0, 1).
704 Padding(0, 1).
688 Border(lipgloss.RoundedBorder()).
705 Border(lipgloss.RoundedBorder()).
689 BorderForeground(t.BorderFocus).
706 BorderForeground(t.BorderFocus).
@@ -691,6 +708,8 @@ func (p *permissionDialogCmp) render() string {
691 Render(
708 Render(
692 content,
709 content,
693 )
710 )
711+ p.finalDialogHeight = lipgloss.Height(dialog)
712+ return dialog
694}
713}
695
714
696func (p *permissionDialogCmp) View() string {
715func (p *permissionDialogCmp) View() string {
internal/tui/tui.go+2−3
@@ -264,12 +264,11 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
264 return a, a.handleKeyPressMsg(msg)
264 return a, a.handleKeyPressMsg(msg)
265
265
266 case tea.MouseWheelMsg:
266 case tea.MouseWheelMsg:
267− if a.dialog.HasDialogs() && a.dialog.ActiveDialogID() == permissions.PermissionsDialogID {
267+ if a.dialog.HasDialogs() {
268 u, dialogCmd := a.dialog.Update(msg)
268 u, dialogCmd := a.dialog.Update(msg)
269 a.dialog = u.(dialogs.DialogCmp)
269 a.dialog = u.(dialogs.DialogCmp)
270 cmds = append(cmds, dialogCmd)
270 cmds = append(cmds, dialogCmd)
271− }
271+ } else {
272− if !a.dialog.HasDialogs() {
273 updated, pageCmd := a.pages[a.currentPage].Update(msg)
272 updated, pageCmd := a.pages[a.currentPage].Update(msg)
274 a.pages[a.currentPage] = updated.(util.Model)
273 a.pages[a.currentPage] = updated.(util.Model)
275 cmds = append(cmds, pageCmd)
274 cmds = append(cmds, pageCmd)