Project

General

Profile

Actions

Bug #13861

open

WTabWidget does not size contents correctly when inserted with ContentLoading::Lazy

Added by Stefan Bn 9 days ago. Updated 8 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
07/24/2025
Due date:
% Done:

0%

Estimated time:

Description

This behavior started after Wt 4.11.1 and is present in current version Wt 4.12.0. I use many WTabWidgets that are stretched to maximum size in layouts and this issue breakes my entire GUI.

If a tab is added with ContentLoading::Lazy the contents aren't rendered to full size of the surrounding WTabWidget upon first selection (see attached image). Switching between tabs or resizing the browser window leads to a refresh to the correct size.

This refers to current version Wt 4.12.0 on Windows 10; I see this behavior in Firefox and Edge. If compiled with Wt 4.11.1 or earlier this issue is not there.

Sample code that shows the problem:

#include <Wt/WApplication.h>
#include <Wt/WBootstrap5Theme.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WVBoxLayout.h>
#include <Wt/WText.h>
#include <Wt/WTabWidget.h>
#include <Wt/WPanel.h>

using namespace Wt;

std::unique_ptr<WPanel> createDummyPanel(WString title)
{
    auto panel = std::make_unique<WPanel>();

    auto cont = panel->setCentralWidget(std::make_unique<WContainerWidget>());
    cont->decorationStyle().setBackgroundColor(WColor("lightblue"));
    cont->addNew<WText>(title);

    return panel;
}

std::unique_ptr<WApplication> createHelloApplication(const WEnvironment &env)
{
    auto app = std::make_unique<WApplication>(env);

    auto theme = std::make_shared<WBootstrap5Theme>();
    app->setTheme(theme);

    auto vl = app->root()->setLayout(std::make_unique<WVBoxLayout>());

    auto tabs = vl->addWidget(std::make_unique<WTabWidget>(), 1);

    tabs->addTab(createDummyPanel("Content 1 - Should be Full-Size"), "Tab 1", ContentLoading::Lazy);

    // Problem:
    // Tab2 isn't rendered full-size on first selection, due to ContentLoading::Lazy
    // Tab3 with ContentLoading::Eager is okay
    tabs->addTab(createDummyPanel("Content 2 - Should be Full-Size"), "Tab 2", ContentLoading::Lazy);
    tabs->addTab(createDummyPanel("Content 3 - Should be Full-Size"), "Tab 3", ContentLoading::Eager);

    vl->addWidget(std::make_unique<WText>("Bottom"));

    return app;
}

int main(int argc, char *argv[])
{
    return Wt::WRun(argc, argv, &createHelloApplication);
}

Files

TabSizeProblem.JPG (21.2 KB) TabSizeProblem.JPG Stefan Bn, 07/24/2025 01:31 PM
Actions #1

Updated by Stefan Bn 8 days ago

In addition: I see the same behavior when a WMenu is used togehter with a WStackedWidget. When the stacked contents are added using deferCreate, then the size of the content with strechted layout is not shown full size upon first selection. Resizing the browser window only a little bit refreshs the view and the widgets jump to correct size.

auto dummyMenuItem = menu->addItem("Dummy Item", deferCreate(std::bind(&DumyView::createView, this)));
Actions

Also available in: Atom PDF