From 60cdf4ae14781af9533ccba68423d02197537c71 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Wed, 27 Dec 2023 10:07:34 +0100 Subject: [PATCH] feat(neon_framework): skip renaming if it was not changed Signed-off-by: Nikolas Rimikis --- packages/neon_framework/lib/src/widgets/dialog.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/neon_framework/lib/src/widgets/dialog.dart b/packages/neon_framework/lib/src/widgets/dialog.dart index 8ef1ed067f7..9caaddbbd37 100644 --- a/packages/neon_framework/lib/src/widgets/dialog.dart +++ b/packages/neon_framework/lib/src/widgets/dialog.dart @@ -291,6 +291,7 @@ class NeonConfirmationDialog extends StatelessWidget { /// Use `showRenameDialog` to display this dialog. /// /// When submitted the new value will be popped as a `String`. +/// If the new value is equal to the provided one `null` will be popped. class NeonRenameDialog extends StatefulWidget { /// Creates a new Neon rename dialog. const NeonRenameDialog({ @@ -328,8 +329,14 @@ class _NeonRenameDialogState extends State { } void submit() { - if (formKey.currentState!.validate()) { + if (!formKey.currentState!.validate()) { + return; + } + + if (controller.text != widget.value) { Navigator.of(context).pop(controller.text); + } else { + Navigator.of(context).pop(); } }