I am writing this answer since I do not have enough reputation to write a comment yet.
I have found this post whilst having the same problem and tried to recreate my own problematic code, since this was asked for in the comments, so this is just what I think could be the problem, rather than a solution.
In my case, the problem is the display type.
The element containing the text will only stay as wide as the text itself when using display: inline.
But since using this is not always an option, I think what the original poster needs is a way to limit the width to the text with non-inline display attribute values and without using width: min-content.
<div style="width: 65px;background: black;">
<span style="display: block;background: gray;">Short Text</span>
</div>