-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(ui-macos): keep editable TextField single-line (#10155) #10157
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Fixed macOS `TextField` wrapping to multiple lines when its text was wider than | ||
| the field. `perry-ui-macos`'s `create()` built the field from | ||
| `NSTextField::textFieldWithString`, whose cell wraps and grows, and never | ||
| overrode it — so a fixed-width field grew tall instead of scrolling, unlike | ||
| every other backend. The cell is now configured for single-line editing | ||
| (`usesSingleLineMode`, `scrollable`, `wraps = false`, clipping line-break mode), | ||
| matching iOS / GTK4 / Android / Windows. Multiline input keeps its own widget, | ||
| `TextArea`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Smoke test for issue #10155: a fixed-width editable TextField on macOS must | ||
| // stay one line and scroll horizontally, not wrap and grow tall. | ||
| // Run the built app and confirm the long value shows on one line inside the | ||
| // 220px-wide field, matching a normal single-line NSTextField. | ||
| import { App, VStack, Text, TextField, State, stateBindTextfield, widgetSetWidth } from "perry/ui" | ||
|
|
||
| const text = State("assignee = currentUser() AND statusCategory != Done AND project = SU") | ||
| const field = TextField("query...", (value: string) => text.set(value)) | ||
| stateBindTextfield(text, field) | ||
| widgetSetWidth(field, 220) | ||
|
|
||
| App({ | ||
| title: "issue 10155 single-line TextField", | ||
| width: 300, | ||
| height: 160, | ||
| body: VStack(12, [ | ||
| Text("Field below must stay one line and scroll, not wrap:"), | ||
| field, | ||
| ]), | ||
| }) | ||
|
Comment on lines
+1
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Run this case in the macOS UI test path
Add this scenario to the registered 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve the single-line invariant at the generic text mutator boundary.
TextFieldreturns aWidget, and the public text mutators also acceptWidget. On macOS,textSetWrapsandtextSetNumberOfLinesset theNSTextFieldcell to wrapping.textSetTruncationModechanges its line-break mode. These calls can violate the documented single-lineTextFieldcontract.Track the widget kind at registration and reject or normalize these mutators for
TextField. Do not reject everyNSTextField, becauseTextuses the same native class.🤖 Prompt for AI Agents