mirror of
https://github.com/flutter/flutter
synced 2024-09-12 21:01:59 +00:00
made SelectionArea alignment consistent between web and other platform (#150037)
Currently, when text is placed inside a SelectionArea widget that's nested within a Column widget, it results in misalignment, causing the text to appear centered instead of aligned as intended. This was originally #149552 but had issues with my branch. *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* Fixes #148934 Fixes #121053 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
parent
a3f6a2bdc7
commit
9056c0b192
|
@ -135,7 +135,6 @@ class PlatformSelectableRegionContextMenu extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: Alignment.center,
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Positioned.fill(
|
const Positioned.fill(
|
||||||
child: HtmlElementView(
|
child: HtmlElementView(
|
||||||
|
|
|
@ -3594,6 +3594,27 @@ void main() {
|
||||||
skip: kIsWeb, // [intended] Web uses its native context menu.
|
skip: kIsWeb, // [intended] Web uses its native context menu.
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/121053.
|
||||||
|
testWidgets('Ensure SelectionArea does not affect the layout of its children', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const MaterialApp(
|
||||||
|
home: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
SelectionArea(child: Text('row 1')),
|
||||||
|
Text('row 2'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final double xOffset1 = tester.getTopLeft(find.text('row 1')).dx;
|
||||||
|
final double xOffset2 = tester.getTopLeft(find.text('row 2')).dx;
|
||||||
|
expect(xOffset1, xOffset2);
|
||||||
|
},
|
||||||
|
variant: TargetPlatformVariant.all(),
|
||||||
|
);
|
||||||
|
|
||||||
testWidgets('the selection behavior when clicking `Copy` item in mobile platforms', (WidgetTester tester) async {
|
testWidgets('the selection behavior when clicking `Copy` item in mobile platforms', (WidgetTester tester) async {
|
||||||
List<ContextMenuButtonItem> buttonItems = <ContextMenuButtonItem>[];
|
List<ContextMenuButtonItem> buttonItems = <ContextMenuButtonItem>[];
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
|
|
Loading…
Reference in a new issue