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

Display error message when button in email still has its default text #2451

Merged
merged 6 commits into from
Dec 28, 2024

Conversation

helihard
Copy link
Collaborator

Description

This PR adds an error message to be displayed in case the user has not changed the default text of a button in an email draft.

Screenshots

button-default-text-warning

Changes

  • Adds an error message. When the default text of the button has been changed, the name of the element ('Button') is displayed in the right-hand 'Content' column.

Notes to reviewer

When playing around a bit, I found some possible areas for improvement.

  • Both the previous code and my code does allow for the button text to consist only of whitespaces.
  • Neither version allows for the button text to consist of zero characters, but as a result of this PR, the error message reads 'This button still has the default text' also in the case of an empty (0 characters) button.

I should be able to just add a second error message (along the lines of 'This button must have some text', 'This button cannot be empty), just let me know if I should file this as a new issue or simply build on the current issue and re-PR it.

Related issues

Resolves #2444

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I have looked at the preview build and I have reviewed the code changes.

I was super happy to see this. I'm hoping to be able to make a release sometime next week, but there's not much to release, so this would be lovely to merge. 😊

I did find two things that I think could be improved, one of which is related to the problem you raised in the PR:

Neither version allows for the button text to consist of zero characters, but as a result of this PR, the error message reads 'This button still has the default text' also in the case of an empty (0 characters) button.

Comment on lines 43 to 45
data.buttonText
? messages.editor.tools.button.title()
: messages.editor.tools.button.settings.defaultButtonTextWarning()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that maybe the error message could be moved out of the header? I mean the block is still a button even if it's invalid, so I think it might be a bit jarring to replace the title like this.

Compare this with how invalid links are handled in paragraph/text blocks. It's still a text block and titled as such ("Text"), but there's an additional warning underneath.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Of course that would be a more suitable way to handle it. I'll be back with an updated version shortly.

Copy link
Collaborator Author

@helihard helihard Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

several-button-text-errors

It seems to be doing what I intended for it to do: displays error when the button has its default text, when the button has zero characters and when the button text consists of only whitespaces. So I went a bit beyond the feedback, but I can easily undo that bit if it isn't needed :)

@@ -63,6 +63,7 @@ export default makeMessages('feat.emails', {
noButtonText: m('Click to change this text!'),
},
settings: {
defaultButtonTextWarning: m('This button still has the default text'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can change this to something that works regardless of what the error is? Something like "Make sure to add your text to the button" or something like that?

I trust you to come up with something reasonable. Just wanted to propose a bit of a shortcut here that might work. 😊

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! This is much better IMO. I have tried the preview build and reviewed the code changes and I think this is ready to merge. 🎉

@@ -33,6 +33,9 @@ const ButtonBlockListItem: FC<ButtonBlockLIstItemProps> = ({
}, 400);

const error = inputValue.length > 0 && !formatUrl(inputValue);
const buttonTextError =
!data.buttonText?.replaceAll('&nbsp;', '').trim().length ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 💯

@richardolsson richardolsson merged commit 008960a into main Dec 28, 2024
6 checks passed
@richardolsson richardolsson deleted the issue-2444/button-default-text-error branch December 28, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Email: Show error message if button has default text
2 participants