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

Swapping handles order is prevented #532

Merged
merged 1 commit into from Sep 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/zefyr/lib/src/widgets/text_selection.dart
Expand Up @@ -495,8 +495,8 @@ class _TextSelectionHandleOverlayState
);
break;
}
// if (newSelection.baseOffset >= newSelection.extentOffset)
// return; // don't allow order swapping.
if (newSelection.baseOffset >= newSelection.extentOffset)
return; // don't allow order swapping.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question here. It looks like on iOS even though swapping is allowed it'll also result in actual handles swap.

Meaning if extent < base then we actually flip the values as well so that base becomes the lower value.

On Android, I believe, handles don't swap (but I might be wrong). Have you tested it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested Flutter's TextField behavior on both iOS & Android. They behave the same => now swapping

But you are right, on iOS native text, selection handles do swap.

Should we mimic Flutter's TextField?
otherwise we need to define the desired behavior on each supported platforms

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I think we should stay consistent with what Flutter does so that we get the same behavior within a Flutter app as a whole.

Thanks for the details!


widget.onSelectionHandleChanged(newSelection);
}
Expand Down