Skip to content

Commit 816fa3a

Browse files
committed
Reset outbound link highlights when switching between source posts
1 parent 1bedc2e commit 816fa3a

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
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' => 'd32bef74f4fde0b9ec6b');
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' => '2bf214d8db4f3289591c');

build/content-helper/dashboard-page.js

Lines changed: 5 additions & 5 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/link-counter.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* WordPress dependencies
33
*/
44
import { Button } from '@wordpress/components';
5-
import { useDispatch } from '@wordpress/data';
5+
import { useDispatch, useSelect } from '@wordpress/data';
66
import { useEffect, useState } from '@wordpress/element';
77
import { __, sprintf } from '@wordpress/i18n';
88

@@ -67,6 +67,7 @@ export const LinkCounter = ( {
6767
smart: 0,
6868
} );
6969

70+
const storePreviewLinkType = useSelect( ( select ) => select( TrafficBoostStore ).getPreviewLinkType(), [] );
7071
const { setPreviewLinkType } = useDispatch( TrafficBoostStore );
7172

7273
useEffect( () => {
@@ -108,6 +109,17 @@ export const LinkCounter = ( {
108109
setPreviewLinkType( initialSelectedLinkType );
109110
}, [ initialSelectedLinkType, setPreviewLinkType ] );
110111

112+
/**
113+
* Updates the selected link type when changed externally via the store.
114+
*
115+
* @since 3.20.1
116+
*/
117+
useEffect( () => {
118+
if ( storePreviewLinkType !== selectedLinkType ) {
119+
setSelectedLinkType( storePreviewLinkType );
120+
}
121+
}, [ selectedLinkType, storePreviewLinkType ] );
122+
111123
/**
112124
* Handles click events on link type buttons.
113125
*

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const TrafficBoostPreview = ( {
9494
setSelectedTab,
9595
setIsAccepting,
9696
setIsRemoving,
97+
setPreviewLinkType,
9798
} = useDispatch( TrafficBoostStore );
9899

99100
/**
@@ -115,7 +116,8 @@ export const TrafficBoostPreview = ( {
115116
setActivePost( activeLink.targetPost );
116117
setIsInboundLink( ! activeLink.isSuggestion );
117118
setSelectedText( null );
118-
}, [ activeLink ] );
119+
setPreviewLinkType( null );
120+
}, [ activeLink, setPreviewLinkType ] );
119121

120122
/**
121123
* Sets the total items and item index based on the active link.

0 commit comments

Comments
 (0)