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
Merged
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 @@ -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! 💯

!data.buttonText;
return (
<BlockListItemBase
excerpt={data.buttonText}
Expand All @@ -41,6 +44,9 @@ const ButtonBlockListItem: FC<ButtonBlockLIstItemProps> = ({
selected={selected}
title={messages.editor.tools.button.title()}
>
{buttonTextError && (
<Msg id={messageIds.editor.tools.button.settings.buttonTextWarning} />
)}
<Box display="flex" flexDirection="column">
<Box paddingBottom={1} paddingTop={2}>
<TextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export default function blockProblems(block: OutputBlockData): BlockProblem[] {

if (!block.data.buttonText) {
blockProblems.push(BlockProblem.DEFAULT_BUTTON_TEXT);
} else if (!block.data.buttonText.replaceAll('&nbsp;', '').trim().length) {
blockProblems.push(BlockProblem.BUTTON_TEXT_MISSING);
}
} else if (block.type === BLOCK_TYPES.PARAGRAPH) {
const container = document.createElement('div');
Expand Down
1 change: 1 addition & 0 deletions src/features/emails/l10n/messageIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default makeMessages('feat.emails', {
noButtonText: m('Click to change this text!'),
},
settings: {
buttonTextWarning: m('Make sure to add your text to the button'),
invalidUrl: m('This is not a valid link'),
testLink: m('Click to test link'),
urlLabel: m('Link url'),
Expand Down
1 change: 1 addition & 0 deletions src/features/emails/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export type EmailContent = {
export enum BlockProblem {
INVALID_BUTTON_URL = 'invalidButtonURL',
DEFAULT_BUTTON_TEXT = 'defaultButtonText',
BUTTON_TEXT_MISSING = 'buttonTextMissing',
INVALID_LINK_URL = 'invalidLinkURL',
}

Expand Down
Loading