Workaround for nesting <Text> inside <TextInput> #16445
Jihoo Byeon (jihoobyeon)
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I had to nest
<Text>inside<TextInput>for my project.but as mentioned at #5689 it is not supported, both Fabric and Paper.
so I tried to modify
Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp,and could able to make some workaround for Fabric at v0.81.35.
What did i do:
First, I added private method named
ApplyTextAttributesto structWindowsTextInputComponentView:as you can see, I only added
color,fontFamilyandlineHeight, which I needed.Then I modified
updateStatefrom this:to this - invoking newly created
ApplyTextAttributes:and also modified
OnTextUpdated:and lastly, changed a line in
createVisual:winrt::check_hresult(m_textServices->TxSendMessage(EM_SETTEXTMODE, TM_RICHTEXT, 0, &res));originally the second argument was
TM_PLAINTEXT.as this workaround, I could able to show selected 3 attributes at RNW app.
but as you know, there are much more style props on Text component - as mentioned in here and some more inherited from View style props(e. g.
backgroundColor)Would full implementation of those props be possible?
if it's impossible, how many props can be included at nearest future releases?
All reactions