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: can't find context after popover disappear
appflowyaf98febcb0e9
diff --git a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dartindex 398a2206ae..5dca885414 100644--- a/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart+++ b/frontend/app_flowy/lib/plugins/grid/presentation/widgets/header/field_cell_action_sheet.dart@@ -93,9 +93,9 @@ class _EditFieldButton extends StatelessWidget {}class _FieldOperationList extends StatelessWidget {- final GridFieldCellContext fieldData;+ final GridFieldCellContext fieldContext;final VoidCallback onDismissed;- const _FieldOperationList(this.fieldData, this.onDismissed, {Key? key})+ const _FieldOperationList(this.fieldContext, this.onDismissed, {Key? key}): super(key: key);@override@@ -118,14 +118,14 @@ class _FieldOperationList extends StatelessWidget {bool enable = true;switch (action) {case FieldAction.delete:- enable = !fieldData.field.isPrimary;+ enable = !fieldContext.field.isPrimary;break;default:break;}return FieldActionCell(- fieldId: fieldData.field.id,+ fieldContext: fieldContext,action: action,onTap: onDismissed,enable: enable,@@ -136,13 +136,13 @@ class _FieldOperationList extends StatelessWidget {}class FieldActionCell extends StatelessWidget {- final String fieldId;+ final GridFieldCellContext fieldContext;final VoidCallback onTap;final FieldAction action;final bool enable;const FieldActionCell({- required this.fieldId,+ required this.fieldContext,required this.action,required this.onTap,required this.enable,@@ -161,7 +161,7 @@ class FieldActionCell extends StatelessWidget {hoverColor: theme.hover,onTap: () {if (enable) {- action.run(context);+ action.run(context, fieldContext);onTap();}},@@ -202,7 +202,7 @@ extension _FieldActionExtension on FieldAction {}}- void run(BuildContext context) {+ void run(BuildContext context, GridFieldCellContext fieldContext) {switch (this) {case FieldAction.hide:context@@ -210,18 +210,24 @@ extension _FieldActionExtension on FieldAction {.add(const FieldActionSheetEvent.hideField());break;case FieldAction.duplicate:- context- .read<FieldActionSheetBloc>()- .add(const FieldActionSheetEvent.duplicateField());+ PopoverContainer.of(context).close();++ FieldService(+ gridId: fieldContext.gridId,+ fieldId: fieldContext.field.id,+ ).duplicateField();+break;case FieldAction.delete:PopoverContainer.of(context).close();+NavigatorAlertDialog(title: LocaleKeys.grid_field_deleteFieldPromptMessage.tr(),confirm: () {- context- .read<FieldActionSheetBloc>()- .add(const FieldActionSheetEvent.deleteField());+ FieldService(+ gridId: fieldContext.gridId,+ fieldId: fieldContext.field.id,+ ).deleteField();},).show(context);diff --git a/frontend/app_flowy/packages/appflowy_popover/lib/src/popover.dart b/frontend/app_flowy/packages/appflowy_popover/lib/src/popover.dartindex a817572c66..6b666c278c 100644--- a/frontend/app_flowy/packages/appflowy_popover/lib/src/popover.dart+++ b/frontend/app_flowy/packages/appflowy_popover/lib/src/popover.dart@@ -136,7 +136,6 @@ class PopoverState extends State<Popover> {return Stack(children: children);});-_rootEntry.addEntry(context, this, newEntry, widget.asBarrier);}@@ -243,7 +242,7 @@ class PopoverContainerState extends State<PopoverContainer> {);}- close() => widget.onClose();+ void close() => widget.onClose();- closeAll() => widget.onCloseAll();+ void closeAll() => widget.onCloseAll();}