Closed Paril closed 5 months ago
I confirmed that https://github.com/mikke89/RmlUi/pull/559 doesn't fix this use-case, so I'm not sure if this is just an unrelated bug or if I've set something wrong... it seems to be specific to inline-flex
, though. It always wants to fill the entire parent.
Ah, I just spotted what I was missing from the docs:
In RCSS, inline-flex boxes are required to have their widths set to a definite (non-auto) value.
That would do it, and is quite problematic here since I don't know how long the text is going to be (localization, etc). Is this effectively what shrink-to-fit addresses?
EDIT2: Removing Style::Display::InlineTable
from the check in GetShrinkToFitWidth
and adding it here:
// Apply the shrink-to-fit algorithm here to find the width of the element.
// See CSS 2.1 section 10.3.7 for when this should be applied.
const bool shrink_to_fit = !replaced_element &&
((computed.float_() != Style::Float::None) || (absolutely_positioned && inset_auto) ||
(computed.display() == Style::Display::InlineBlock || computed.display() == Style::Display::InlineFlex));
seems to enable this to work as I expect, but it certainly can't be that simple and probably breaks other things...
I'm not sure how to describe this issue, but, here's the full rml & rcss to reproduce it:
In RmlUi, the inner .control elements are stretched all the way to fill the outer container; they should be fitting their content tightly. If you use the same css in an HTML layout engine, the results are as expected:![](https://i.imgur.com/21UfcYl.png)
However, this is the result I'm getting - I mimicked the result by adding![](https://i.imgur.com/sK6GYMZ.png)
width: 100%;
on .control:Is this related to the "improved shrink to fit" PR, or is this a different issue entirely?
If I use the
Rml::Debugger
, the values are correct for the two inner elements (width 24px for img, ~130px for the text), but the width of the .control always ends up being 1620px.Using
inline-block
instead ofinline-flex
also fixes it, but I wanted to use flex for the inner elements of the block.