Skip to content

Commit

Permalink
Improve the default text logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
miina committed Jun 30, 2020
1 parent 4198936 commit 40d252a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/src/edit-story/components/panels/pageAttachment/index.js
Expand Up @@ -48,6 +48,7 @@ function PageAttachmentPanel() {
const { pageAttachment = {} } = currentPage;
const defaultCTA = __('Learn more', 'web-stories');
const { url, ctaText = defaultCTA } = pageAttachment;
const [_ctaText, _setCtaText] = useState(ctaText);

const updatePageAttachment = useCallback(
(value) => {
Expand All @@ -71,7 +72,7 @@ function PageAttachmentPanel() {
!isValidUrl(withProtocol(url || ''))
);

const isDefault = ctaText === defaultCTA;
const isDefault = _ctaText === defaultCTA;
return (
<SimplePanel
name="pageAttachment"
Expand Down Expand Up @@ -101,12 +102,13 @@ function PageAttachmentPanel() {
{Boolean(url) && !isInvalidUrl && (
<Row>
<ExpandedTextInput
onChange={(value) =>
onChange={(value) => _setCtaText(value)}
onBlur={(value) =>
updatePageAttachment({ ctaText: value ? value : defaultCTA })
}
value={ctaText || defaultCTA}
value={_ctaText}
aria-label={__('Edit: Page Attachment CTA text', 'web-stories')}
clear={Boolean(ctaText) && !isDefault}
clear={Boolean(_ctaText) && !isDefault}
suffix={isDefault ? __('default', 'web-stories') : null}
width={isDefault ? 85 : null}
/>
Expand Down

0 comments on commit 40d252a

Please sign in to comment.