Skip to content

Commit

Permalink
Resolve focus jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora authored and dab246 committed Aug 6, 2024
1 parent 51eecb3 commit cab454f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/src/widgets/html_editor_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
StreamSubscription<MessageEvent>? _editorJSListener;
StreamSubscription<MessageEvent>? _summernoteOnLoadListener;
static const String _summernoteLoadedMessage = '_HtmlEditorWidgetWebState::summernoteLoaded';
final _focusNode = FocusNode();

@override
void initState() {
Expand Down Expand Up @@ -634,7 +635,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {

@override
Widget build(BuildContext context) {
return SizedBox(
final child = SizedBox(
height: widget.htmlEditorOptions.autoAdjustHeight
? actualHeight
: widget.otherOptions.height,
Expand Down Expand Up @@ -674,6 +675,10 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
],
),
);

return Focus(
focusNode: _focusNode,
child: child);
}

/// Adds the callbacks the user set into JavaScript
Expand Down Expand Up @@ -811,6 +816,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
c.onEnter!.call();
}
if (data['type'].contains('onFocus')) {
_focusNode.requestFocus();
c.onFocus!.call();
}
if (data['type'].contains('onBlur')) {
Expand Down Expand Up @@ -988,6 +994,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
void dispose() {
_editorJSListener?.cancel();
_summernoteOnLoadListener?.cancel();
_focusNode.dispose();
super.dispose();
}
}

0 comments on commit cab454f

Please sign in to comment.