From 924f57181b4f7cdde1f11dc25d29e8bb497a90ed Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 12 Jun 2026 18:22:45 +0200 Subject: [PATCH] Tables: Headers: fixed label being clipped early to reserve space for a sort marker even when no sort marker is displayed. Amend 892b48e2d6: while fixing auto fit this was ditched. --- docs/CHANGELOG.txt | 3 +++ imgui_tables.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4f600ed78..eb1e84202 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -58,6 +58,9 @@ Other Changes: - Tables: - Context Menu: added a "Reset" sub-menu with a "Reset Visibility" option. (which is greyed out when using default settings) + - Headers: fixed label being clipped early to reserve space for a sort marker + even when no sort marker is displayed. Auto-fitting a column still accounts + for the possible marker, so that sorting after an auto-fit doesn't clip the label. - Fonts: - Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to disable embedding either fonts separately. (#9407) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index a306a0077..405f6852f 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -3288,7 +3288,9 @@ void ImGui::TableHeader(const char* label) } // Sort order arrow - const float ellipsis_max = ImMax(cell_r.Max.x - w_arrow - w_sort_text, label_pos.x); + // - Only clip label for a visible arrow. Auto-fit still accounts for a possible arrow, but when + // manually sized smaller we don't clip the label for the sake of an arrow that isn't displayed. + const float ellipsis_max = ImMax(cell_r.Max.x - (sort_arrow ? w_arrow + w_sort_text : 0.0f), label_pos.x); if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort)) { if (column->SortOrder != -1)