Prevent TextField height changes when switching echo modes

QQuickTextInput may report a larger contentHeight for password replacement characters and some Unicode glyphs than for regular text. As a result, TextField implicitHeight could change when switching between normal and password echo modes.

Introduce a hidden TextInput used to determine a stable minimum single-line content height and use it when calculating implicitHeight. The actual contentHeight is still respected, so wrapped or multi-line content can continue to grow vertically.

This avoids geometry jumps while preserving dynamic height behavior.

I would appreciate it if someone could suggest a cleaner solution. That said, I'd like to point out that addressing the issue on the C++ side (KQuickStyleItem) wasn't feasible, because all we have there is the background. Even if we were able to calculate its height correctly (which is hard to accomplish with sizeFromContents alone), we would only be visually hiding the TextField jump — the underlying issue itself would still remain.

Issue:

Info for testing:

Fonts are default:

image

Apps for testing:

kirigami2gallery (Text Field), pkexec or any TextField - just paste there ● or █

Styles:

QT_QUICK_CONTROLS_STYLE=org.kde.desktop + QT_STYLE_OVERRIDE=fusion or QT_STYLE_OVERRIDE=windows, in some apps (e.g. pkexec) - QT_STYLE_OVERRIDE=oxygen

Merge request reports

Loading