Open s0nx opened 1 month ago
Thanks for the reproducer!
I believe the problem is that ftxui/dom
was made without knowing ftxui/component
will be something.
The hbox
selection is computed by:
void ComputeRequirement() override {
requirement_.min_x = 0;
requirement_.min_y = 0;
requirement_.flex_grow_x = 0;
requirement_.flex_grow_y = 0;
requirement_.flex_shrink_x = 0;
requirement_.flex_shrink_y = 0;
requirement_.selection = Requirement::NORMAL;
for (auto& child : children_) {
child->ComputeRequirement();
if (requirement_.selection < child->requirement().selection) {
requirement_.selection = child->requirement().selection;
requirement_.selected_box = child->requirement().selected_box;
requirement_.selected_box.x_min += requirement_.min_x;
requirement_.selected_box.x_max += requirement_.min_x;
}
requirement_.min_x += child->requirement().min_x;
requirement_.min_y =
std::max(requirement_.min_y, child->requirement().min_y);
}
}
So, we are keeping the selection of the child with the largest priority among focused
and selected
.
In your case, none of the button are focused
, but they are all selected
. So, the frame
is focusing the first one.
The Container::Horizontal
doesn't really specify which of the children must be prioritized.
I will be very busy this month. If you have some propositions or want to submit a PR, we can discuss them if you are interested.
Let's say we have a vertical split and both top and bottom components are of
Container::Vertical
type. If we added some child components which areContainer::Vertical / Container::Horizontal
themselves to the top or bottom parent components, the current scroll position resets to 0 when the parent component is not focused.Here is the simple reproducer:
That's not happening when child component is not a container itself (
Button
for example). I've tried to capture the problem:When i move the focus from
Nottub #30
button toright split button
, the vertical scroller moves all the way to the top. That's not happening iftop_comp
consists ofButton
components only. The scroller stays in place.