Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9f233917
Unverified
Commit
9f233917
authored
Nov 02, 2022
by
htoor3
Committed by
GitHub
Nov 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Changes to web keyboard selection shortcuts for more consistent behavior (#114264)
parent
45c3b028
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
7 deletions
+108
-7
default_text_editing_shortcuts.dart
...utter/lib/src/widgets/default_text_editing_shortcuts.dart
+2
-6
editable_text_shortcuts_test.dart
...es/flutter/test/widgets/editable_text_shortcuts_test.dart
+106
-1
No files found.
packages/flutter/lib/src/widgets/default_text_editing_shortcuts.dart
View file @
9f233917
...
@@ -402,22 +402,16 @@ class DefaultTextEditingShortcuts extends StatelessWidget {
...
@@ -402,22 +402,16 @@ class DefaultTextEditingShortcuts extends StatelessWidget {
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
,
alt:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
,
meta:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowLeft
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowRight
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
pageUp
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
pageUp
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
pageDown
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
pageDown
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
end
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
SingleActivator
(
LogicalKeyboardKey
.
end
,
shift:
true
):
DoNothingAndStopPropagationTextIntent
(),
...
@@ -445,6 +439,8 @@ class DefaultTextEditingShortcuts extends StatelessWidget {
...
@@ -445,6 +439,8 @@ class DefaultTextEditingShortcuts extends StatelessWidget {
const
SingleActivator
(
LogicalKeyboardKey
.
escape
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
escape
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
tab
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
tab
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
tab
,
shift:
true
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
tab
,
shift:
true
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
,
alt:
true
):
const
DoNothingAndStopPropagationTextIntent
(),
const
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
,
alt:
true
):
const
DoNothingAndStopPropagationTextIntent
(),
};
};
static
Map
<
ShortcutActivator
,
Intent
>
get
_shortcuts
{
static
Map
<
ShortcutActivator
,
Intent
>
get
_shortcuts
{
...
...
packages/flutter/test/widgets/editable_text_shortcuts_test.dart
View file @
9f233917
...
@@ -67,6 +67,8 @@ void main() {
...
@@ -67,6 +67,8 @@ void main() {
'0123456789ABCDEFGHIJ'
'0123456789ABCDEFGHIJ'
'0123456789ABCDEFGHIJ'
'0123456789ABCDEFGHIJ'
'0123456789ABCDEFGHIJ'
;
'0123456789ABCDEFGHIJ'
;
const
String
testVerticalText
=
'1
\n
2
\n
3
\n
4
\n
5
\n
6
\n
7
\n
8
\n
9'
;
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
FocusNode
focusNode
=
FocusNode
();
final
FocusNode
focusNode
=
FocusNode
();
...
@@ -2043,7 +2045,8 @@ void main() {
...
@@ -2043,7 +2045,8 @@ void main() {
},
variant:
appleOnly
);
},
variant:
appleOnly
);
});
});
testWidgets
(
'vertical movement'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'vertical movement outside of selection'
,
(
WidgetTester
tester
)
async
{
controller
.
text
=
testText
;
controller
.
text
=
testText
;
controller
.
selection
=
const
TextSelection
.
collapsed
(
controller
.
selection
=
const
TextSelection
.
collapsed
(
offset:
0
,
offset:
0
,
...
@@ -2052,6 +2055,10 @@ void main() {
...
@@ -2052,6 +2055,10 @@ void main() {
await
tester
.
pumpWidget
(
buildEditableText
());
await
tester
.
pumpWidget
(
buildEditableText
());
for
(
final
SingleActivator
activator
in
allModifierVariants
(
LogicalKeyboardKey
.
arrowDown
))
{
for
(
final
SingleActivator
activator
in
allModifierVariants
(
LogicalKeyboardKey
.
arrowDown
))
{
// Skip for the shift shortcut since web accepts it.
if
(
activator
.
shift
)
{
continue
;
}
await
sendKeyCombination
(
tester
,
activator
);
await
sendKeyCombination
(
tester
,
activator
);
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -2201,4 +2208,102 @@ void main() {
...
@@ -2201,4 +2208,102 @@ void main() {
},
variant:
appleOnly
);
},
variant:
appleOnly
);
},
skip:
!
kIsWeb
);
// [intended] specific tests target web.
},
skip:
!
kIsWeb
);
// [intended] specific tests target web.
group
(
'Web does accept'
,
()
{
testWidgets
(
'select up'
,
(
WidgetTester
tester
)
async
{
const
SingleActivator
selectUp
=
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
);
controller
.
text
=
testVerticalText
;
controller
.
selection
=
const
TextSelection
.
collapsed
(
offset:
5
,
);
await
tester
.
pumpWidget
(
buildEditableText
());
await
sendKeyCombination
(
tester
,
selectUp
);
await
tester
.
pump
();
expect
(
controller
.
text
,
testVerticalText
);
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
5
,
extentOffset:
3
),
// selection extends upwards from 5
reason:
selectUp
.
toString
(),
);
},
variant:
TargetPlatformVariant
.
desktop
());
testWidgets
(
'select down'
,
(
WidgetTester
tester
)
async
{
const
SingleActivator
selectDown
=
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
);
controller
.
text
=
testVerticalText
;
controller
.
selection
=
const
TextSelection
.
collapsed
(
offset:
5
,
);
await
tester
.
pumpWidget
(
buildEditableText
());
await
sendKeyCombination
(
tester
,
selectDown
);
await
tester
.
pump
();
expect
(
controller
.
text
,
testVerticalText
);
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
5
,
extentOffset:
7
),
// selection extends downwards from 5
reason:
selectDown
.
toString
(),
);
},
variant:
TargetPlatformVariant
.
desktop
());
testWidgets
(
'select all up'
,
(
WidgetTester
tester
)
async
{
final
bool
isMacOS
=
defaultTargetPlatform
==
TargetPlatform
.
macOS
;
final
SingleActivator
selectAllUp
=
isMacOS
?
const
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
,
meta:
true
)
:
const
SingleActivator
(
LogicalKeyboardKey
.
arrowUp
,
shift:
true
,
alt:
true
);
controller
.
text
=
testVerticalText
;
controller
.
selection
=
const
TextSelection
.
collapsed
(
offset:
5
,
);
await
tester
.
pumpWidget
(
buildEditableText
());
await
sendKeyCombination
(
tester
,
selectAllUp
);
await
tester
.
pump
();
expect
(
controller
.
text
,
testVerticalText
);
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
5
,
extentOffset:
0
),
// selection extends all the way up
reason:
selectAllUp
.
toString
(),
);
},
variant:
TargetPlatformVariant
.
desktop
());
testWidgets
(
'select all down'
,
(
WidgetTester
tester
)
async
{
final
bool
isMacOS
=
defaultTargetPlatform
==
TargetPlatform
.
macOS
;
final
SingleActivator
selectAllDown
=
isMacOS
?
const
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
,
meta:
true
)
:
const
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
,
shift:
true
,
alt:
true
);
controller
.
text
=
testVerticalText
;
controller
.
selection
=
const
TextSelection
.
collapsed
(
offset:
5
,
);
await
tester
.
pumpWidget
(
buildEditableText
());
await
sendKeyCombination
(
tester
,
selectAllDown
);
await
tester
.
pump
();
expect
(
controller
.
text
,
testVerticalText
);
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
5
,
extentOffset:
17
),
// selection extends all the way down
reason:
selectAllDown
.
toString
(),
);
},
variant:
TargetPlatformVariant
.
desktop
());
},
skip:
!
kIsWeb
);
// [intended] specific tests target web.
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment