Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix(flutter_desktop): select option kanban groups not updating #6369
Richard Shiue99889b995086
diff --git a/frontend/appflowy_flutter/integration_test/desktop/board/board_group_test.dart b/frontend/appflowy_flutter/integration_test/desktop/board/board_group_test.dartindex 68848503c4..3eedbdb3bf 100644--- a/frontend/appflowy_flutter/integration_test/desktop/board/board_group_test.dart+++ b/frontend/appflowy_flutter/integration_test/desktop/board/board_group_test.dart@@ -1,17 +1,21 @@+import 'package:appflowy/plugins/database/board/presentation/widgets/board_column_header.dart';import 'package:appflowy/plugins/database/widgets/card/card.dart';import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart';+import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_cell_editor.dart';+import 'package:appflowy/plugins/database/widgets/field/type_option_editor/select/select_option_editor.dart';import 'package:appflowy/plugins/database/widgets/row/row_property.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';-import 'package:flutter/widgets.dart';+import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:integration_test/integration_test.dart';+import '../../shared/database_test_op.dart';import '../../shared/util.dart';void main() {IntegrationTestWidgetsFlutterBinding.ensureInitialized();- group('board group test', () {+ group('board group test:', () {testWidgets('move row to another group', (tester) async {const card1Name = 'Card 1';await tester.initializeAppFlowy();@@ -46,5 +50,105 @@ void main() {final card1StatusText = tester.widget<Text>(card1StatusFinder).data;expect(card1StatusText, 'Doing');});++ testWidgets('rename group', (tester) async {+ await tester.initializeAppFlowy();+ await tester.tapAnonymousSignInButton();++ await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);++ final headers = find.byType(BoardColumnHeader);+ expect(headers, findsNWidgets(4));++ // try to tap no status+ final noStatus = headers.first;+ expect(+ find.descendant(of: noStatus, matching: find.text("No Status")),+ findsOneWidget,+ );+ await tester.tapButton(noStatus);+ expect(+ find.descendant(of: noStatus, matching: find.byType(TextField)),+ findsNothing,+ );++ // tap on To Do and edit it+ final todo = headers.at(1);+ expect(+ find.descendant(of: todo, matching: find.text("To Do")),+ findsOneWidget,+ );+ await tester.tapButton(todo);+ await tester.enterText(+ find.descendant(of: todo, matching: find.byType(TextField)),+ "tada",+ );+ await tester.testTextInput.receiveAction(TextInputAction.done);+ await tester.pumpAndSettle();++ final newHeaders = find.byType(BoardColumnHeader);+ expect(newHeaders, findsNWidgets(4));+ final tada = find.byType(BoardColumnHeader).at(1);+ expect(+ find.descendant(of: tada, matching: find.byType(TextField)),+ findsNothing,+ );+ expect(+ find.descendant(+ of: tada,+ matching: find.text("tada"),+ ),+ findsOneWidget,+ );+ });++ testWidgets('edit select option from row detail', (tester) async {+ const card1Name = 'Card 1';++ await tester.initializeAppFlowy();+ await tester.tapAnonymousSignInButton();++ await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);++ await tester.tapButton(+ find.descendant(+ of: find.byType(RowCard),+ matching: find.text(card1Name),+ ),+ );++ await tester.tapGridFieldWithNameInRowDetailPage("Status");+ await tester.tapButton(+ find.byWidgetPredicate(+ (widget) =>+ widget is SelectOptionTagCell && widget.option.name == "To Do",+ ),+ );+ final editor = find.byType(SelectOptionEditor);+ await tester.enterText(+ find.descendant(of: editor, matching: find.byType(TextField)),+ "tada",+ );+ await tester.testTextInput.receiveAction(TextInputAction.done);+ await tester.pumpAndSettle();++ await tester.dismissFieldEditor();+ await tester.dismissRowDetailPage();++ final newHeaders = find.byType(BoardColumnHeader);+ expect(newHeaders, findsNWidgets(4));+ final tada = find.byType(BoardColumnHeader).at(1);+ expect(+ find.descendant(of: tada, matching: find.byType(TextField)),+ findsNothing,+ );+ expect(+ find.descendant(+ of: tada,+ matching: find.text("tada"),+ ),+ findsOneWidget,+ );+ });});}diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rsindex fbfcf3c28c..e5873507d4 100644--- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs+++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs@@ -26,7 +26,6 @@ use crate::services::database_view::{notify_did_update_setting, notify_did_update_sort, DatabaseLayoutDepsResolver,DatabaseViewChangedNotifier, DatabaseViewChangedReceiverRunner,};-use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOption};use crate::services::field_settings::FieldSettings;use crate::services::filter::{Filter, FilterChangeset, FilterController};use crate::services::group::{@@ -905,7 +904,11 @@ impl DatabaseViewEditor {// If the id of the grouping field is equal to the updated field's id// and something critical changed, then we need to update the group settingif self.is_grouping_field(field_id).await- && self.did_type_options_change(field.field_type.into(), old_field, &field)+ && (old_field.field_type != field.field_type+ || matches!(+ FieldType::from(field.field_type),+ FieldType::SingleSelect | FieldType::MultiSelect+ )){self.v_group_by_field(field_id).await?;}@@ -914,59 +917,6 @@ impl DatabaseViewEditor {Ok(())}- /// This method returns true if the field type options have changed enough to warrant- /// updating the group by field in the client.- ///- /// This check should only be done when the field is the grouping field, and will by default- /// return false for fields that don't quality to be grouped by.- ///- fn did_type_options_change(- &self,- field_type: FieldType,- old_field: &Field,- new_field: &Field,- ) -> bool {- if old_field.field_type != new_field.field_type {- return true;- }-- if !field_type.can_be_group() {- return false;- }-- match field_type {- // Checkbox & Url can also be grouped by, but they work differently to select fields- // and thus don't need to be updated when the type option itself changes- FieldType::Checkbox | FieldType::URL => false,- FieldType::SingleSelect => {- let old_field_type_option = old_field.get_type_option::<SingleSelectTypeOption>(field_type);- let new_field_type_option = new_field.get_type_option::<SingleSelectTypeOption>(field_type);-- if let (Some(old_field_type_option), Some(new_field_type_option)) =- (old_field_type_option, new_field_type_option)- {- return old_field_type_option.options.len() != new_field_type_option.options.len();- }-- false- },- FieldType::MultiSelect => {- let old_field_type_option = old_field.get_type_option::<MultiSelectTypeOption>(field_type);- let new_field_type_option = new_field.get_type_option::<MultiSelectTypeOption>(field_type);-- if let (Some(old_field_type_option), Some(new_field_type_option)) =- (old_field_type_option, new_field_type_option)- {- return old_field_type_option.options.len() != new_field_type_option.options.len();- }-- false- },- // All other FieldTypes- _ => false,- }- }-/// Called when a grouping field is updated.#[tracing::instrument(level = "debug", skip_all, err)]pub async fn v_group_by_field(&self, field_id: &str) -> FlowyResult<()> {