Remove unnecessary early return in the RichTextWithButton component

MAILPOET-6431
This commit is contained in:
Oluwaseun Olorunsola
2025-02-12 21:18:48 +01:00
committed by Oluwaseun Olorunsola
parent ee513fd871
commit f96e74cf96
4 changed files with 6 additions and 6 deletions

View File

@@ -93,7 +93,7 @@ export function EmailSidebarExtensionBody({ RichTextWithButton }) {
<>
<RichTextWithButton
attributeName="subject"
attributeValue={mailpoetEmailData?.subject || ' '}
attributeValue={mailpoetEmailData?.subject}
updateProperty={updateEmailMailPoetProperty}
label={__('Subject', 'mailpoet')}
labelSuffix={
@@ -109,7 +109,7 @@ export function EmailSidebarExtensionBody({ RichTextWithButton }) {
<RichTextWithButton
attributeName="preheader"
attributeValue={mailpoetEmailData?.preheader || 'preheader'}
attributeValue={mailpoetEmailData?.preheader}
updateProperty={updateEmailMailPoetProperty}
label={__('Preview text', 'mailpoet')}
labelSuffix={

View File

@@ -59,7 +59,7 @@ class CreateAndSendEmailUsingGutenbergCest {
$i->click('[data-automation-id="email_editor_send_button"]');
$i->waitForElement('[name="subject"]');
$subject = $i->grabValueFrom('[name="subject"]');
verify($subject)->equals('My New Subject '); // we need extra space here because the subject input-textarea contains some space as default
verify($subject)->equals('My New Subject');
$i->waitForText('My New Preview Text');
$i->fillField('sender_name', 'John Doe');
$i->fillField('sender_address', 'john.doe@example.com');

View File

@@ -18,7 +18,7 @@ type Replacement = {
function getChildElement( rootElement: HTMLElement ): HTMLElement | null {
let currentElement: HTMLElement | null = rootElement;
while ( currentElement && currentElement.children.length > 0 ) {
while ( currentElement && currentElement?.children?.length > 0 ) {
// Traverse into the first child element
currentElement = currentElement.children[ 0 ] as HTMLElement;
}

View File

@@ -97,13 +97,13 @@ export function RichTextWithButton( {
</>
);
if ( ! attributeValue ) {
if ( ! attributeName ) {
return null;
}
return (
<BaseControl
id=""
id="" // See https://github.com/mailpoet/mailpoet/pull/6089#discussion_r1952126850 to understand why the ID is empty
label={ finalLabel }
className={ `mailpoet-settings-panel__${ attributeName }-text` }
help={ help }