Skip to content

Commit

Permalink
AI Assistant: Remove Breve highlight popover when feature is disabled (
Browse files Browse the repository at this point in the history
…#38814)

* remove highlight popover on feature disable

* changelog
  • Loading branch information
dhasilva authored Aug 12, 2024
1 parent 310bff2 commit 3383165
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: Remove Breve highlight popover when feature is disabled
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const useInit = init => {

const Controls = ( { blocks, disabledFeatures } ) => {
const [ gradeLevel, setGradeLevel ] = useState( null );
const { toggleFeature, toggleProofread } = useDispatch( 'jetpack/ai-breve' );
const { toggleFeature, toggleProofread, setPopoverHover, setHighlightHover, setPopoverAnchor } =
useDispatch( 'jetpack/ai-breve' );
const { tracks } = useAnalytics();

const isProofreadEnabled = useSelect(
Expand Down Expand Up @@ -82,6 +83,19 @@ const Controls = ( { blocks, disabledFeatures } ) => {
// Update the grade level immediately on first load.
useInit( updateGradeLevel );

// Disable the popover when proofread or a feature is disabled.
useEffect( () => {
setPopoverHover( false );
setHighlightHover( false );
setPopoverAnchor( { target: null, virtual: null } );
}, [
setPopoverHover,
setHighlightHover,
setPopoverAnchor,
isProofreadEnabled,
disabledFeatures,
] );

return (
<div className="jetpack-ai-proofread">
<p> { __( 'Improve your writing with AI.', 'jetpack' ) }</p>
Expand Down

0 comments on commit 3383165

Please sign in to comment.