-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Update default selectionHeightStyle
and selectionWidthStyle
for EditableText
#167762
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
Update default selectionHeightStyle
and selectionWidthStyle
for EditableText
#167762
Conversation
673b3cc
to
2d72f21
Compare
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
0b3f5ca
to
b0a86f0
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
f1379ae
to
21b08e8
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
21b08e8
to
7fd1f42
Compare
@@ -283,8 +283,8 @@ class CupertinoTextField extends StatefulWidget { | |||
this.cursorRadius = const Radius.circular(2.0), | |||
this.cursorOpacityAnimates = true, | |||
this.cursorColor, | |||
this.selectionHeightStyle = ui.BoxHeightStyle.tight, |
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.
I see this a lot in the framework where higher level widgets set their default to the same as their basic counterpart, i.e. TextField sets the same defaults as EditableText. Is this a pattern we want to be strict about? Can we just keep the defaults in EditableText and have TextField fall back on that. This PR does this for selectionHeightStyle and selectionWidthStyle, but i'm curious what others think.
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.
This has come up a few times and I have softly decided to support setting the default everywhere. I just sent you some notes I wrote about it.
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.
Hm it seems a drawback of omitting the default value here is that the property becomes nullable? It seems like a small usability win to have a non-nullable property if we set the default everywhere.
Also, not setting the default property also makes this particular change a breaking change. I'd lean towards avoid a breaking change if possible.
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.
Ah but since EditableText.defaultSelectionHeightStyle
and EditableText.defaultSelectionWidthStyle
are non-const, we can't actually use them as default values in a const
constructor? If that's the case, I'm OK with changing these to be null by default.
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.
Yeah it won't be possible to set the defaults because the selectionStyle getters are non-const. Even in the non-const constructors if the parameter is a named one its default value has to be const. Is this considered a breaking change because TextField().selectionHeightStyle/selectionWidthStyle
now return null
?
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.
Is this considered a breaking change because
TextField().selectionHeightStyle/selectionWidthStyle
now returnnull
?
Strictly speaking, yes.
One way to avoid this breaking change would be by making TextField().selectionHeightStyle/selectionWidthStyle
getters that return EditableText.defaultSelectionWidthStyle/defaultSelectionWidthStyle
instead of null
. That feels a bit weird though, I suspect the breaking change is the better solution long-term.
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -324,8 +324,8 @@ class RenderEditable extends RenderBox | |||
bool paintCursorAboveText = false, | |||
Offset cursorOffset = Offset.zero, | |||
double devicePixelRatio = 1.0, | |||
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, | |||
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, | |||
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.max, |
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.
I set this to a reasonable default that wouldn't cause a line with runs of different heights to create "ledges".
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.
I'm on board with that. I've seen the "ledges" problem come up before and wondered why we didn't do this in the first place. We can always undo it if it breaks something we're not thinking of.
2e52273
to
9a92460
Compare
@@ -1659,9 +1659,9 @@ void main() { | |||
composingRect = editable.getRectForComposingRange(const TextRange(start: 6, end: 7))!; | |||
expect(composingRect, const Rect.fromLTRB(0.0, 14.0, 14.0, 28.0)); | |||
composingRect = editable.getRectForComposingRange(const TextRange(start: 7, end: 8))!; // H | |||
expect(composingRect, const Rect.fromLTRB(14.0, 18.0, 24.0, 28.0)); |
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.
This test change makes sense since now that the default is BoxHeightStyle.max
, these rects have a height of the largest span on the line which are the WidgetSpan
s in this test with a height of 14.0
.
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
166f040
to
4ce5255
Compare
selectionHeightStyle
selectionHeightStyle
for EditableText
a4c9c39
to
54c1043
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
One style that doesn't seem possible using the currently available ![]() |
selectionHeightStyle
for EditableText
selectionHeightStyle
and selectionWidthStyle
for EditableText
f2787cb
to
ccfd64a
Compare
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
…yle` for `EditableText` (flutter/flutter#167762)
This change updates the default
selectionHeightStyle
andselectionWidthStyle
forEditableText
to more closely match the behavior on native platforms.Native Selection Style Behavior
Android Native Behavior
iOS Native Behavior
macOS Native Behavior
Flutter Selection Style Behavior
Flutter Before Behavior
This was the behavior on all platforms before this change.
Flutter Chrome After Behavior
This is the behavior on all chrome web after this change.
Flutter Safari After Behavior
This is the behavior on Safari after this change. (all iOS browsers, and Safari on macOS).
Flutter Native After Behavior
This is the behavior on native platforms after this change.
Fixes #68675
Pre-launch Checklist
///
).