Skip to content

Commit f6861b3

Browse files
authored
fix (tables): Table columns become hidden in an empty table #2449 (#2475)
1 parent e11d7d1 commit f6861b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mvTables.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,17 @@ void mvTable::draw(ImDrawList* drawlist, float x, float y)
362362

363363
// columns
364364
int columnnum = 0;
365+
int last_row = ImGui::TableGetRowIndex();
365366
for (auto& item : childslots[0])
366367
{
367368
ImGuiTableColumnFlags flags = ImGui::TableGetColumnFlags(columnnum);
368369
item->state.lastFrameUpdate = GContext->frame;
369370
item->state.visible = flags & ImGuiTableColumnFlags_IsVisible;
370371
item->state.hovered = flags & ImGuiTableColumnFlags_IsHovered;
371-
if (item->config.enabled)
372+
// Note: when the table is empty, TableGetColumnFlags will incorrectly return
373+
// zero status flags for all columns. While this is fine for `visible` and `hovered`,
374+
// we definitely don't want to push that zero into `show`.
375+
if (item->config.enabled && last_row >= 0)
372376
{
373377
// Sync the flag with the actual column state controlled by the
374378
// user via context menu.

0 commit comments

Comments
 (0)