Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename untitled view #6789

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ class TabBarItemButton extends StatelessWidget {
case TabBarViewAction.rename:
NavigatorTextFieldDialog(
title: LocaleKeys.menuAppHeader_renameDialog.tr(),
value: view.name,
value: view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: view.name,
onConfirm: (newValue, _) {
context.read<DatabaseTabBarBloc>().add(
DatabaseTabBarEvent.renameView(view.id, newValue),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class FavoriteMoreActions extends StatelessWidget {
NavigatorTextFieldDialog(
title: LocaleKeys.disclosureAction_rename.tr(),
autoSelectAllText: true,
value: view.name,
value: view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: view.name,
maxLength: 256,
onConfirm: (newValue, _) {
// can not use bloc here because it has been disposed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Future<void> createViewAndShowRenameDialogIfNeeded(
if (context.mounted && showRenameDialog) {
await NavigatorTextFieldDialog(
title: dialogTitle,
value: defaultName,
value: defaultName.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: defaultName,
autoSelectAllText: true,
onConfirm: createView,
).show(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
NavigatorTextFieldDialog(
title: LocaleKeys.disclosureAction_rename.tr(),
autoSelectAllText: true,
value: widget.view.name,
value: widget.view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: widget.view.name,
maxLength: 256,
onConfirm: (newValue, _) {
context.read<ViewBloc>().add(ViewEvent.rename(newValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class _NavigatorTextFieldDialogState extends State<NavigatorTextFieldDialog> {
@override
void initState() {
super.initState();
newValue = widget.value;
newValue = widget.value.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: widget.value;
controller.text = newValue;
if (widget.autoSelectAllText) {
controller.selection = TextSelection(
Expand Down
Loading