From 40d252a4bba29a6d1cab42ce52b9c1fc3a913874 Mon Sep 17 00:00:00 2001 From: Miina Sikk Date: Tue, 30 Jun 2020 15:30:11 +0200 Subject: [PATCH] Improve the default text logic. --- .../components/panels/pageAttachment/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/assets/src/edit-story/components/panels/pageAttachment/index.js b/assets/src/edit-story/components/panels/pageAttachment/index.js index e896ea7fde2a..16e1c6dc1f3e 100644 --- a/assets/src/edit-story/components/panels/pageAttachment/index.js +++ b/assets/src/edit-story/components/panels/pageAttachment/index.js @@ -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) => { @@ -71,7 +72,7 @@ function PageAttachmentPanel() { !isValidUrl(withProtocol(url || '')) ); - const isDefault = ctaText === defaultCTA; + const isDefault = _ctaText === defaultCTA; return ( + 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} />