From f88660647c0b836bb9a976e022cbf03334337dda Mon Sep 17 00:00:00 2001 From: pigeoner Date: Mon, 18 Nov 2024 16:10:38 +0800 Subject: [PATCH] fix: adjust the popup direction of combobox to adaptive --- desktop/ui/GetStartedView.qml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/desktop/ui/GetStartedView.qml b/desktop/ui/GetStartedView.qml index 4182fb9..b0eb0e7 100644 --- a/desktop/ui/GetStartedView.qml +++ b/desktop/ui/GetStartedView.qml @@ -127,6 +127,26 @@ Item { model: daemon.availableAddresses width: 360 + + popup.y: { + // Get the absolute coordinates of the combo box in the window + var absoluteY = addressCombo.mapToGlobal(0, 0).y; + // Get window height + var windowHeight = Window.window ? Window.window.height : Screen.height; + // Calculate the available space below + var spaceBelow = windowHeight - (absoluteY + height); + // Calculate the available space above + var spaceAbove = absoluteY; + // Default height of popup + var popupHeight = popup.height; + + // If there is not enough space below and enough space above, pop it up + if (spaceBelow < popupHeight && spaceAbove >= popupHeight) { + return -popupHeight; + } + // By default, it will pop up downwards + return height; + } } TextField {