From 8fdc91bd9f8fa3ac1ecbd3cb5a7e1a5b6155b250 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 2 Apr 2024 13:29:15 +0100 Subject: [PATCH] Fix a29766d: Wrong scrolling dropdown list position with RTL. (#12412) (cherry picked from commit 975082659087af55f9da3738cb657334e6111625) --- src/widgets/dropdown.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index b136d06323..195e6c0c93 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -154,7 +154,12 @@ struct DropdownWindow : Window { this->position.y = button_rect.bottom + 1; } - this->position.x = (_current_text_dir == TD_RTL) ? button_rect.right + 1 - (int)widget_dim.width : button_rect.left; + if (_current_text_dir == TD_RTL) { + /* In case the list is wider than the parent button, the list should be right aligned to the button and overflow to the left. */ + this->position.x = button_rect.right + 1 - (int)(widget_dim.width + (list_dim.height > widget_dim.height ? NWidgetScrollbar::GetVerticalDimension().width : 0)); + } else { + this->position.x = button_rect.left; + } this->items_dim = widget_dim; this->GetWidget(WID_DM_SHOW_SCROLL)->SetDisplayedPlane(list_dim.height > widget_dim.height ? 0 : SZSP_NONE);