[GH-ISSUE #1001] InputField placeholder text is word-wrapped #725

Closed
opened 2026-03-04 01:07:17 +03:00 by kerem · 2 comments
Owner

Originally created by @kivattt on GitHub (Jun 24, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/1001

In my project using tview, I have an InputField with SetFieldWidth(45), with some placeholder text.
I noticed when the second word in the placeholder was long enough, it would suddenly disappear and show only the first word!

This code demonstrates the issue:

package main

import "github.com/rivo/tview"

func main() {
        inputField := tview.NewInputField().SetFieldWidth(45)

        // The placeholder will only show "This is a sentence with a very"
        inputField.SetPlaceholder("This is a sentence with a very looooooooooooooooooooong word")

        if err := tview.NewApplication().SetRoot(inputField, true).Run(); err != nil {
                panic(err)
        }
}

InputField uses a TextArea to draw the placeholder
github.com/rivo/tview@c38c796625/inputfield.go (L475)

Which uses a TextView with word-wrapping enabled by default
github.com/rivo/tview@c38c796625/textarea.go (L1325-L1326)

If this is intended behaviour, it would be nice to have something like .SetWrap() or .SetWordWrap() as part of InputField

Originally created by @kivattt on GitHub (Jun 24, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/1001 In my project using tview, I have an InputField with SetFieldWidth(45), with some placeholder text. I noticed when the second word in the placeholder was long enough, it would suddenly disappear and show only the first word! This code demonstrates the issue: ```go package main import "github.com/rivo/tview" func main() { inputField := tview.NewInputField().SetFieldWidth(45) // The placeholder will only show "This is a sentence with a very" inputField.SetPlaceholder("This is a sentence with a very looooooooooooooooooooong word") if err := tview.NewApplication().SetRoot(inputField, true).Run(); err != nil { panic(err) } } ``` InputField uses a TextArea to draw the placeholder https://github.com/rivo/tview/blob/c38c796625fb04d2e677f0e737e42b079a8731ca/inputfield.go#L475 Which uses a TextView with word-wrapping enabled by default https://github.com/rivo/tview/blob/c38c796625fb04d2e677f0e737e42b079a8731ca/textarea.go#L1325-L1326 If this is intended behaviour, it would be nice to have something like `.SetWrap()` or `.SetWordWrap()` as part of InputField
kerem closed this issue 2026-03-04 01:07:18 +03:00
Author
Owner

@rivo commented on GitHub (Jun 26, 2024):

So you would like to see partial words in the placeholder text? I wonder what the rationale is for that. Consider this example:

"Would you like some ass" ("...istance?")

I'm not sure that this would be good for the user.

Maybe you can explain why you'd want this?

<!-- gh-comment-id:2191857705 --> @rivo commented on GitHub (Jun 26, 2024): So you would like to see partial words in the placeholder text? I wonder what the rationale is for that. Consider this example: > "Would you like some ass" ("...istance?") I'm not sure that this would be good for the user. Maybe you can explain why you'd want this?
Author
Owner

@kivattt commented on GitHub (Jun 29, 2024):

I agree that makes sense for most cases where you show normal text as words. I should have clarified that I am using an input field with a command as the placeholder where I do not want word-wrapping because it can hide arguments from the user
image
Notice the aqua colored text below the input field shows the start of a command argument, which isn't hinted at in the inputfield placeholder

<!-- gh-comment-id:2198142787 --> @kivattt commented on GitHub (Jun 29, 2024): I agree that makes sense for most cases where you show normal text as words. I should have clarified that I am using an input field with a command as the placeholder where I do not want word-wrapping because it can hide arguments from the user ![image](https://github.com/rivo/tview/assets/49201105/5b0fad52-4ecf-4594-bffa-e0daffb0dbfa) Notice the aqua colored text below the input field shows the start of a command argument, which isn't hinted at in the inputfield placeholder
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#725
No description provided.