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
d031a61a
Unverified
Commit
d031a61a
authored
Feb 09, 2021
by
Tomasz Gucio
Committed by
GitHub
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RenderEditable keys listener back in attach() (#75614)
parent
5a2c917d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+2
-0
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+61
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
d031a61a
...
@@ -1639,6 +1639,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
...
@@ -1639,6 +1639,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
_offset
.
addListener
(
markNeedsPaint
);
_offset
.
addListener
(
markNeedsPaint
);
_showHideCursor
();
_showHideCursor
();
_showCursor
.
addListener
(
_showHideCursor
);
_showCursor
.
addListener
(
_showHideCursor
);
if
(
_listenerAttached
)
RawKeyboard
.
instance
.
addListener
(
_handleKeyEvent
);
}
}
@override
@override
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
d031a61a
...
@@ -955,6 +955,67 @@ void main() {
...
@@ -955,6 +955,67 @@ void main() {
expect
(
delegate
.
textEditingValue
.
text
,
''
);
expect
(
delegate
.
textEditingValue
.
text
,
''
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61021
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61021
test
(
'arrow keys work after detaching the widget and attaching it again'
,
()
async
{
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
()
..
textEditingValue
=
const
TextEditingValue
(
text:
'W Szczebrzeszynie chrząszcz brzmi w trzcinie'
,
selection:
TextSelection
.
collapsed
(
offset:
0
),
);
final
ViewportOffset
viewportOffset
=
ViewportOffset
.
zero
();
final
RenderEditable
editable
=
RenderEditable
(
backgroundCursorColor:
Colors
.
grey
,
selectionColor:
Colors
.
black
,
textDirection:
TextDirection
.
ltr
,
cursorColor:
Colors
.
red
,
offset:
viewportOffset
,
textSelectionDelegate:
delegate
,
onSelectionChanged:
(
TextSelection
selection
,
RenderEditable
renderObject
,
SelectionChangedCause
cause
)
{
renderObject
.
selection
=
selection
;
},
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
text:
const
TextSpan
(
text:
'W Szczebrzeszynie chrząszcz brzmi w trzcinie'
,
style:
TextStyle
(
height:
1.0
,
fontSize:
10.0
,
fontFamily:
'Ahem'
,
),
),
selection:
const
TextSelection
.
collapsed
(
offset:
0
,
),
);
final
PipelineOwner
pipelineOwner
=
PipelineOwner
();
editable
.
attach
(
pipelineOwner
);
editable
.
hasFocus
=
true
;
editable
.
detach
();
layout
(
editable
);
editable
.
hasFocus
=
true
;
editable
.
selectPositionAt
(
from:
Offset
.
zero
,
cause:
SelectionChangedCause
.
tap
);
editable
.
selection
=
const
TextSelection
.
collapsed
(
offset:
0
);
pumpFrame
();
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
arrowRight
,
platform:
'android'
);
expect
(
editable
.
selection
?.
isCollapsed
,
true
);
expect
(
editable
.
selection
?.
baseOffset
,
4
);
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
arrowLeft
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
arrowLeft
,
platform:
'android'
);
expect
(
editable
.
selection
?.
isCollapsed
,
true
);
expect
(
editable
.
selection
?.
baseOffset
,
3
);
await
simulateKeyDownEvent
(
LogicalKeyboardKey
.
delete
,
platform:
'android'
);
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
delete
,
platform:
'android'
);
expect
(
delegate
.
textEditingValue
.
text
,
'W Sczebrzeszynie chrząszcz brzmi w trzcinie'
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61021
test
(
'arrow keys with selection text'
,
()
async
{
test
(
'arrow keys with selection text'
,
()
async
{
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
ViewportOffset
viewportOffset
=
ViewportOffset
.
zero
();
final
ViewportOffset
viewportOffset
=
ViewportOffset
.
zero
();
...
...
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