on main help sign in
feat(diffview): only process scroll events when pointer is over dialog
commitfb6dab0df3737f81697763ff713d72d6c9d22b26 authorAndrey Nering <andreynering@users.noreply.github.com> dateThu 7 Aug 2025, 11:53 (1 year ago) parent2917109
2 files changed+23−5
internal/tui/components/dialogs/permissions/permissions.go+21−2 internal/tui/tui.go+2−3
internal/tui/components/dialogs/permissions/permissions.go+21−2
@@ -64,6 +64,8 @@ type permissionDialogCmp struct {
6464 positionRow int // Row position for dialog
6565 positionCol int // Column position for dialog
6666
67+ finalDialogHeight int
68+
6769 keyMap KeyMap
6870}
6971
@@ -159,7 +161,7 @@ func (p *permissionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
159161 cmds = append(cmds, cmd)
160162 }
161163 case tea.MouseWheelMsg:
162− if p.supportsDiffView() {
164+ if p.supportsDiffView() && p.isMouseOverDialog(msg.Mouse().X, msg.Mouse().Y) {
163165 switch msg.Button {
164166 case tea.MouseWheelDown:
165167 p.scrollDown()
@@ -196,6 +198,21 @@ func (p *permissionDialogCmp) scrollRight() {
196198 p.contentDirty = true
197199}
198200
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+
199216func (p *permissionDialogCmp) selectCurrentOption() tea.Cmd {
200217 var action PermissionAction
201218
@@ -683,7 +700,7 @@ func (p *permissionDialogCmp) render() string {
683700 }
684701 content := lipgloss.JoinVertical(lipgloss.Top, strs...)
685702
686− return baseStyle.
703+ dialog := baseStyle.
687704 Padding(0, 1).
688705 Border(lipgloss.RoundedBorder()).
689706 BorderForeground(t.BorderFocus).
@@ -691,6 +708,8 @@ func (p *permissionDialogCmp) render() string {
691708 Render(
692709 content,
693710 )
711+ p.finalDialogHeight = lipgloss.Height(dialog)
712+ return dialog
694713}
695714
696715func (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) {
264264 return a, a.handleKeyPressMsg(msg)
265265
266266 case tea.MouseWheelMsg:
267− if a.dialog.HasDialogs() && a.dialog.ActiveDialogID() == permissions.PermissionsDialogID {
267+ if a.dialog.HasDialogs() {
268268 u, dialogCmd := a.dialog.Update(msg)
269269 a.dialog = u.(dialogs.DialogCmp)
270270 cmds = append(cmds, dialogCmd)
271− }
272− if !a.dialog.HasDialogs() {
271+ } else {
273272 updated, pageCmd := a.pages[a.currentPage].Update(msg)
274273 a.pages[a.currentPage] = updated.(util.Model)
275274 cmds = append(cmds, pageCmd)