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: newsletter toggle in editor sidebar has a visually broken active state #41036

Merged
merged 2 commits into from
Jan 16, 2025
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
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Fix: newsletter toggle in editor sidebar has a visually broken active state.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export function NewsletterEmailDocumentSettings() {
const postMetaUpdate = {
...postMeta,
// Meta value is negated, "don't send", but toggle is truthy when enabled "send"
[ META_NAME_FOR_POST_DONT_EMAIL_TO_SUBS ]: ! value,
[ META_NAME_FOR_POST_DONT_EMAIL_TO_SUBS ]: value === 'post-only',
};
setPostMeta( postMetaUpdate );
saveEditedEntityRecord( 'postType', postType, postId );
Expand All @@ -315,7 +315,7 @@ export function NewsletterEmailDocumentSettings() {
const isSendEmailEnabled = useSelect( select => {
const meta = select( editorStore ).getEditedPostAttribute( 'meta' );
// Meta value is negated, "don't send", but toggle is truthy when enabled "send"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether this comment is still necessary. Now that the toggle control value is a string, the code is more self-documenting IMO.

return ! meta?.[ META_NAME_FOR_POST_DONT_EMAIL_TO_SUBS ];
return meta?.[ META_NAME_FOR_POST_DONT_EMAIL_TO_SUBS ] ? 'post-only' : 'post-and-email';
} );

return (
Expand All @@ -333,8 +333,11 @@ export function NewsletterEmailDocumentSettings() {
__nextHasNoMarginBottom={ true }
__next40pxDefaultSize={ true }
>
<ToggleGroupControlOption label={ __( 'Post & email', 'jetpack' ) } value={ true } />
<ToggleGroupControlOption label={ __( 'Post only', 'jetpack' ) } value={ false } />
<ToggleGroupControlOption
label={ __( 'Post & email', 'jetpack' ) }
value="post-and-email"
/>
<ToggleGroupControlOption label={ __( 'Post only', 'jetpack' ) } value="post-only" />
</ToggleGroupControl>
);
} }
Expand Down
Loading