diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart index 4a1f1f05bc..736a379637 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell/desktop_row_detail/desktop_row_detail_checklist_cell.dart @@ -70,10 +70,11 @@ class _ChecklistItemsState extends State { key: ValueKey(task.data.id), task: task, autofocus: widget.state.newTask && index == tasks.length - 1, - onSubmitted: index == tasks.length - 1 - ? () => widget.bloc - .add(const ChecklistCellEvent.createNewTask("")) - : null, + onSubmitted: () { + if (index == tasks.length - 1) { + widget.bloc.add(const ChecklistCellEvent.createNewTask("")); + } + }, ), ), ) diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/checklist_cell_editor.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/checklist_cell_editor.dart index 18c9428ede..324963ad0d 100644 --- a/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/checklist_cell_editor.dart +++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/cell_editor/checklist_cell_editor.dart @@ -187,8 +187,12 @@ class _ChecklistItemState extends State { super.didUpdateWidget(oldWidget); if (widget.task.data.name != oldWidget.task.data.name) { final selection = _textController.selection; - _textController.text = widget.task.data.name; - _textController.selection = selection; + // Ensure the selection offset is within the new text bounds + int offset = selection.start; + if (offset > widget.task.data.name.length) { + offset = widget.task.data.name.length; + } + _textController.selection = TextSelection.collapsed(offset: offset); } } @@ -204,13 +208,20 @@ class _ChecklistItemState extends State { }, actions: { _SelectTaskIntent: CallbackAction<_SelectTaskIntent>( - onInvoke: (_SelectTaskIntent intent) => context - .read() - .add(ChecklistCellEvent.selectTask(widget.task.data.id)), + onInvoke: (_SelectTaskIntent intent) { + // Log.debug("checklist widget on enter"); + context + .read() + .add(ChecklistCellEvent.selectTask(widget.task.data.id)); + return; + }, ), _EndEditingTaskIntent: CallbackAction<_EndEditingTaskIntent>( - onInvoke: (_EndEditingTaskIntent intent) => - _textFieldFocusNode.unfocus(), + onInvoke: (_EndEditingTaskIntent intent) { + // Log.debug("checklist widget on escape"); + _textFieldFocusNode.unfocus(); + return; + }, ), }, shortcuts: { @@ -278,12 +289,14 @@ class _ChecklistItemState extends State { } }, onSubmitted: (description) { - _submitUpdateTaskDescription(description); if (widget.onSubmitted != null) { + // Log.debug("checklist widget on submitted"); widget.onSubmitted?.call(); } else { + // Log.debug("checklist widget Focus next task"); Actions.invoke(context, const NextFocusIntent()); } + _submitUpdateTaskDescription(description); }, ); }, @@ -454,8 +467,7 @@ class _DeleteTaskButtonState extends State<_DeleteTaskButton> { statesController: _materialStatesController, child: FlowySvg( FlowySvgs.delete_s, - color: _materialStatesController.value - .contains(WidgetState.hovered) || + color: _materialStatesController.value.contains(WidgetState.hovered) || _materialStatesController.value.contains(WidgetState.focused) ? Theme.of(context).colorScheme.error : null, diff --git a/frontend/rust-lib/lib-infra/src/priority_task/queue.rs b/frontend/rust-lib/lib-infra/src/priority_task/queue.rs index 2123ef15ca..2b5e6e598d 100644 --- a/frontend/rust-lib/lib-infra/src/priority_task/queue.rs +++ b/frontend/rust-lib/lib-infra/src/priority_task/queue.rs @@ -34,7 +34,8 @@ impl TaskQueue { match self.index_tasks.entry(task.handler_id.clone()) { Entry::Occupied(entry) => { let mut list = entry.get().borrow_mut(); - assert!(list + + debug_assert!(list .peek() .map(|old_id| pending_task.id >= old_id.id) .unwrap_or(true)); diff --git a/frontend/rust-lib/lib-infra/src/priority_task/store.rs b/frontend/rust-lib/lib-infra/src/priority_task/store.rs index b9b2c8599e..bf5d8f0829 100644 --- a/frontend/rust-lib/lib-infra/src/priority_task/store.rs +++ b/frontend/rust-lib/lib-infra/src/priority_task/store.rs @@ -45,7 +45,7 @@ impl TaskStore { } pub(crate) fn next_task_id(&self) -> TaskId { - let _ = self.task_id_counter.fetch_add(1, SeqCst); - self.task_id_counter.load(SeqCst) + let old = self.task_id_counter.fetch_add(1, SeqCst); + old + 1 } }