SwiftcordApp/Swiftcord

Message field does not wrap

cryptoAlgorithm opened this issue · 5 comments

Describe the bug
When typing a long message into the message field, the text does not wrap once it hits the end of the field.
Although newlines work (opt + return), the text does not wrap anymore like it did before with TextEditor

To Reproduce

  1. Type very long text in the message field
  2. Notice how the text does not scroll, but you can still input text into the field
  3. Send the message and note that the text that was entered beyond the width of the field is present

Expected behavior
The text wraps to the next line

Screenshots

Note the cut-off 't' that appears after the cursor

Screenshot 2022-05-26 at 11 46 25 AM

Additional context
Text wrapping used to work while a TextEditor was used, but newlines didn't. Now, its the opposite xD

Was alt-enter handling the reason for switching from TextEditor to TextField? I think we should explore more options for TextEditor handling enter as a commit action and alt enter as an edit action.

Yeah, among other issues that TextEditor brought, like a hardcoded background (someone figured how to override it with a transparent color), and no option for a placeholder hint. Also, there were other issues using it with a ScrollView. The other option is to use AppKit, which allows handling of the raw keydown events, but was very tough.

I might use swiftui-introspect to access the low level NSTextView of the TextEditor to handle keyDown events 🤔

This appears to be fixed in macOS 13, irregardless of whether Xcode 13 or 14 is used to build Swiftcord. So, it appears to be some SwiftUI 'bug' (or maybe its a bug in macOS 13 that fixes this as a side effect?) that was fixed in macOS 13. Either ways, the 'fixed' behaviour in macOS 13 is not what I want (it scrolls horizontally when the field overflows instead of wrapping vertically), so I'll still have to figure out some other solution for this.

Moved to #75