Skip to content

Commit 14a9699

Browse files
authored
Merge pull request #3460 from Parsely/fix/actions-bar-embed-in-highlight
2 parents 04778a0 + 4f61a0b commit 14a9699

File tree

7 files changed

+377
-285
lines changed

7 files changed

+377
-285
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '3fccf4875848f7b21bfe');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'd32bef74f4fde0b9ec6b');

build/content-helper/dashboard-page.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content-helper/dashboard-page/pages/traffic-boost/preview/components/preview-actions.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { Button, CheckboxControl, Icon, Tooltip } from '@wordpress/components';
4+
import { Button, CheckboxControl, Icon } from '@wordpress/components';
55
import { useSelect } from '@wordpress/data';
66
import { useCallback, useState } from '@wordpress/element';
77
import { __ } from '@wordpress/i18n';
8-
import { check, closeSmall, info, undo } from '@wordpress/icons';
8+
import { check, closeSmall, help, undo } from '@wordpress/icons';
99

1010
/**
1111
* Internal dependencies
@@ -135,22 +135,20 @@ export const PreviewActions = ( {
135135
>{ __( 'Reject', 'wp-parsely' ) }</Button>
136136
<VerticalDivider size={ 48 } color="#1e1e1e" />
137137
{ ! selectedText &&
138-
<Tooltip text={ __( 'Highlight text on the page to customize link placement.', 'wp-parsely' ) }>
139-
<div className="traffic-boost-preview-actions-hint">
140-
<div className="traffic-boost-preview-actions-hint-text">
141-
{ __( 'Highlight to customize', 'wp-parsely' ) }
142-
</div>
143-
<Icon icon={ info } />
138+
<div className="traffic-boost-preview-actions-hint">
139+
<Icon icon={ help } />
140+
<div className="traffic-boost-preview-actions-hint-text">
141+
{ __( 'TIP: Customize by selecting different text.', 'wp-parsely' ) }
144142
</div>
145-
</Tooltip>
143+
</div>
146144
}
147145
{ selectedText && (
148146
<Button
149147
variant="tertiary"
150148
onClick={ onRestoreOriginal }
151149
icon={ undo }
152150
>
153-
{ __( 'Clear changes', 'wp-parsely' ) }
151+
{ __( 'Revert', 'wp-parsely' ) }
154152
</Button>
155153
) }
156154
</>
@@ -181,7 +179,7 @@ export const PreviewActions = ( {
181179
onClick={ onRestoreOriginal }
182180
icon={ undo }
183181
>
184-
{ __( 'Clear changes', 'wp-parsely' ) }
182+
{ __( 'Revert', 'wp-parsely' ) }
185183
</Button>
186184
</>
187185
) }

src/content-helper/dashboard-page/pages/traffic-boost/preview/components/preview-iframe.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* WordPress dependencies
33
*/
44
import { Spinner } from '@wordpress/components';
5-
import { throttle, usePrevious } from '@wordpress/compose';
5+
import { usePrevious } from '@wordpress/compose';
66
import { useSelect } from '@wordpress/data';
77
import { useCallback, useEffect, useMemo, useRef } from '@wordpress/element';
88
import { __ } from '@wordpress/i18n';
@@ -15,7 +15,6 @@ import { ErrorIcon } from '../../../../../common/icons/error-icon';
1515
import { TRAFFIC_BOOST_LOADING_MESSAGES, TrafficBoostLink } from '../../provider';
1616
import { TrafficBoostStore } from '../../store';
1717
import { useIframeHighlight } from '../hooks/use-iframe-highlight';
18-
import useResize from '../hooks/use-resize';
1918
import { TextSelection } from '../preview';
2019
import { getContentArea, isExternalURL } from '../utils';
2120
import { PreviewActions } from './preview-actions';
@@ -114,7 +113,6 @@ export const PreviewIframe = ( {
114113
highlightSmartLink,
115114
highlightLinkType,
116115
removeSmartLinkHighlights,
117-
adjustActionsBarPosition,
118116
} = useIframeHighlight( {
119117
iframeRef,
120118
contentAreaRef,
@@ -125,20 +123,6 @@ export const PreviewIframe = ( {
125123
actionsBar,
126124
} );
127125

128-
useResize( iframeRef, throttle(
129-
// At most every 250ms on resize events, check that the actions bar is fully visible
130-
// and adjust its position if needed.
131-
useCallback(
132-
() => {
133-
if ( iframeRef.current !== null ) {
134-
adjustActionsBarPosition( iframeRef.current );
135-
}
136-
},
137-
[ adjustActionsBarPosition ]
138-
),
139-
250
140-
) );
141-
142126
/**
143127
* Hides the admin bar from the iframe if the preview is in frontend mode.
144128
*
@@ -179,6 +163,11 @@ export const PreviewIframe = ( {
179163
iframeDocument.addEventListener( 'click', ( event ) => {
180164
const target = event.target as HTMLElement;
181165

166+
// Allow clicks on the actions bar.
167+
if ( target.closest && target.closest( '.parsely-traffic-boost-actions-container' ) ) {
168+
return;
169+
}
170+
182171
// If the link is outside the content area, don't handle it.
183172
if ( ! contentAreaRef.current?.contains( target ) ) {
184173
event.preventDefault();

0 commit comments

Comments
 (0)