From 2e91b6bc2aa049dc8d847791a5bca6dbcf826164 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:14:19 +0200 Subject: [PATCH] Fix width in modal Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- cmd/usbguard-tui/app.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/usbguard-tui/app.go b/cmd/usbguard-tui/app.go index 599e083..a16a8fe 100644 --- a/cmd/usbguard-tui/app.go +++ b/cmd/usbguard-tui/app.go @@ -2,6 +2,7 @@ package main import ( tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" "github.com/anotherhadi/ilovetui/app" "github.com/anotherhadi/ilovetui/modal" "github.com/anotherhadi/ilovetui/notification" @@ -9,9 +10,10 @@ import ( ) type appModel struct { - core ui.Model - modals modal.Model - notif notification.Model + core ui.Model + modals modal.Model + notif notification.Model + width, height int } func newApp() appModel { @@ -30,6 +32,9 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if _, ok := msg.(app.QuitMsg); ok { return a, tea.Quit } + if sizeMsg, ok := msg.(tea.WindowSizeMsg); ok { + a.width, a.height = sizeMsg.Width, sizeMsg.Height + } a.core.ModalOpen = a.modals.Open() var coreCmd tea.Cmd @@ -43,7 +48,7 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (a appModel) View() tea.View { - bg := a.core.View() + bg := lipgloss.Place(a.width, a.height, lipgloss.Left, lipgloss.Top, a.core.View()) bg = a.modals.Render(bg) bg = a.notif.Render(bg) return tea.View{