Bug #13861
openWTabWidget does not size contents correctly when inserted with ContentLoading::Lazy
0%
Description
This behavior started after Wt 4.11.1 and is present in current version Wt 4.12.0. I use many WTabWidget
s 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
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)));