Skip to content

Commit

Permalink
Refactor the EnableCustomFieldsOption component to improve code reada…
Browse files Browse the repository at this point in the history
…bility and maintainability.
  • Loading branch information
cbravobernal committed Sep 2, 2024
1 parent 7b7788a commit 754a174
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,22 @@ export function EnableCustomFieldsOption( { label, areCustomFieldsEnabled } ) {
const [ isChecked, setIsChecked ] = useState( areCustomFieldsEnabled );

return (
<>
<PreferenceBaseOption
label={ label }
isChecked={ isChecked }
onChange={ setIsChecked }
>
{ isChecked && (
<p className="edit-post-preferences-modal__custom-fields-confirmation-message">
{ __(
'Connected attributes cannot be edited in the block editor while this interface is active.'
) }
</p>
) }
{ isChecked !== areCustomFieldsEnabled && (
<CustomFieldsConfirmation willEnable={ isChecked } />
) }
</PreferenceBaseOption>
</>
<PreferenceBaseOption
label={ label }
isChecked={ isChecked }
onChange={ setIsChecked }
>
{ isChecked && (
<p className="edit-post-preferences-modal__custom-fields-confirmation-message">
{ __(
'Custom fields connected to block attributes cannot be edited in the block editor while this interface is active.'
) }
</p>
) }
{ isChecked !== areCustomFieldsEnabled && (
<CustomFieldsConfirmation willEnable={ isChecked } />
) }
</PreferenceBaseOption>
);
}

Expand Down

0 comments on commit 754a174

Please sign in to comment.