Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial cursor size is smaller than after entering the first character #73

Closed
JWo1F opened this issue Aug 19, 2023 · 2 comments
Closed
Assignees
Labels
AppKit Issues related to the macOS AppKit editor bug Something isn't working UIKit Issues related to the iOS UIKit editor

Comments

@JWo1F
Copy link

JWo1F commented Aug 19, 2023

Describe the bug
If the initial text is set to an empty string, the cursor is smaller than after the first character is entered. If all characters are erased, the cursor size is displayed correctly.

To Reproduce

  1. Create @State private var message = ""
  2. Use as HighlightedTextEditor(text: $message, highlightRules: rules).frame(minHeight: 50)
  3. Now you can see small cursor
  4. Enter one character and you'll see normal cursor
  5. Remove the character and you'll see normal cursos

Expected behavior
The cursor is always displayed at the same size

Screenshots

2023-08-20.02.14.21.mov

Environment
Please include:

  • Exact version of iOS / iPadOS / macOS where your app was running when you saw the bug
    • iOS 16.4, iPhone 11 Pro
  • Is your app using AppKit or UIKit? If your app is for iOS or Mac Catalyst, it is UIKit. If it is for macOS natively, it is using AppKit.
    • UIKit

Additional context
I use flutter, but all the work happens in an independent UIViewController

@JWo1F JWo1F added the bug Something isn't working label Aug 19, 2023
@kyle-n kyle-n added the UIKit Issues related to the iOS UIKit editor label Aug 22, 2023
@kyle-n
Copy link
Owner

kyle-n commented Aug 22, 2023

Confirmed with latest version of HLTE. Issue also occurs in the AppKit editor.

@kyle-n kyle-n added the AppKit Issues related to the macOS AppKit editor label Aug 22, 2023
@kyle-n
Copy link
Owner

kyle-n commented Aug 22, 2023

Fixed in v2.1.2. Use the .introspect() callback:

let baseFont = UIFont.systemFont(ofSize: 40)
struct ContentView: View {
    @State private var text = ""
    var body: some View {
        VStack {
            HighlightedTextEditor(text: $text, highlightRules: [])
            .introspect { editor in
                editor.textView.font = baseFont
            }
        }
        .padding()
    }
}

@kyle-n kyle-n closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AppKit Issues related to the macOS AppKit editor bug Something isn't working UIKit Issues related to the iOS UIKit editor
Projects
None yet
Development

No branches or pull requests

2 participants