Skip to content

Commit

Permalink
fix: focus issue in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Mar 8, 2025
1 parent d10dc21 commit a56569f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lib/features/journal/state/entry_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,14 @@ class EntryController extends _$EntryController {
}
}

void setDirty({required bool value}) {
void setDirty({required bool value, bool requestFocus = true}) {
if (_dirty == value) {
return;
}
_dirty = value;
if (value && requestFocus) {
focusNode.requestFocus();
}
emitState();
}

Expand Down
5 changes: 0 additions & 5 deletions lib/features/journal/ui/widgets/editor/editor_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class EditorWidget extends ConsumerWidget {
final shouldShowEditorToolBar =
entryState.value?.shouldShowEditorToolBar ?? false;

if (shouldShowEditorToolBar) {
focusNode.requestFocus();
}

return Card(
color: shouldShowEditorToolBar
? context.colorScheme.surface.brighten()
Expand Down Expand Up @@ -75,7 +71,6 @@ class EditorWidget extends ConsumerWidget {
cursorColor: context.colorScheme.onSurface,
selectionColor: context.colorScheme.primary.withAlpha(127),
),
autoFocus: shouldShowEditorToolBar,
minHeight: minHeight,
placeholder: context.messages.editorPlaceholder,
padding: EdgeInsets.only(
Expand Down
5 changes: 4 additions & 1 deletion lib/features/tasks/ui/task_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class _TaskFormState extends ConsumerState<TaskForm> {
maxLines: null,
style: Theme.of(context).textTheme.titleLarge,
name: 'title',
onChanged: (_) => notifier.setDirty(value: true),
onChanged: (_) => notifier.setDirty(
value: true,
requestFocus: false,
),
),
inputSpacer,
Row(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lotti
description: Achieve your goals and keep your data private with Lotti.
publish_to: 'none'
version: 0.9.576+2912
version: 0.9.576+2913

msix_config:
display_name: LottiApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void main() {
EditorWidget(entryId: testTextEntry.meta.id),
),
);

await tester.pumpAndSettle();

final boldIconFinder = find.byIcon(Icons.format_bold);
Expand Down

0 comments on commit a56569f

Please sign in to comment.