Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Assistant: Remove Breve highlight popover when feature is disabled #38814

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading