fix: preserve letterSpacing and shadows from selectedTextStyle in text editor input#788
fix: preserve letterSpacing and shadows from selectedTextStyle in text editor input#788faizahmaddae wants to merge 1 commit intohm21:stablefrom
Conversation
3545871 to
69df52e
Compare
|
@faizahmaddae Thanks for creating the PR and sorry for the late review. I remember we added this cuz some fonts had alignment issues, and this fixed the problem (which is weird i know). However, I think the best approach would be to add it to the |
|
Thanks for the feedback! I've updated the PR based on your suggestion. Instead of removing the hard-coded
Both properties are nullable, so users who need the font's native behavior can set them to The This way:
Please take a look when you get a chance! |
…torStyle Instead of hard-coding letterSpacing: 0 and shadows: [] in the text input copyWith, move these values into TextEditorStyle as configurable properties with the same defaults: - inputLetterSpacing (default: 0) — fixes font alignment issues - inputShadows (default: []) — prevents unwanted shadow rendering This preserves the existing behavior by default while allowing users to override these values (e.g. set to null) when they need the font's native letter spacing or shadows. Both hintStyle and style in TextEditorInput now read from these style properties.
5844762 to
61589f9
Compare
Problem
The
TextEditorInputwidget hard-codesletterSpacing: 0andshadows: []in its stylecopyWithcall (text_editor_input.dart#L206-L212):This means any
letterSpacingorshadowsset onselectedTextStyle(e.g. viasetTextStyle(style.copyWith(letterSpacing: 5))) is silently discarded in the live text input preview.Observed behavior
hintStylealso overrides)LayerWidgetTextItem)The values are correctly stored on the
TextLayerand render properly once the text is placed on the canvas, but users cannot see the effect while editing. This makes letter spacing and shadow controls appear broken during the editing experience.Root cause trace
TextEditorState.setTextStyle(style.copyWith(letterSpacing: value))→selectedTextStyleis updated correctlyTextEditorInputreceives updatedselectedTextStyleas a prop ✅_buildInputField()appliesselectedTextStyle.copyWith(letterSpacing: 0, shadows: [])→ overrides both values ❌RoundedBackgroundTextFieldreceivesstylewith zeroed-out values → preview shows no spacing or shadowsFix
Removed the
letterSpacing: 0andshadows: []lines so the input field respects whatever values are already set onselectedTextStyle. When these properties are not explicitly set, they default tonull(Flutter's default behavior), so there is no change in behavior for the default case.Impact
letterSpacing/shadowsare not explicitly set (defaults tonull)LayerWidgetTextItempreserves both properties)