Skip to content

Commit

Permalink
fix: now discussion sidebar modal appears above the fold
Browse files Browse the repository at this point in the history
  • Loading branch information
SundasNoreen committed Sep 12, 2023
1 parent fb2be35 commit 01da103
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/components/TinyMCEEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';

import { Editor } from '@tinymce/tinymce-react';
import { useParams } from 'react-router';
import { useLocation, useParams } from 'react-router';
// TinyMCE so the global var exists
// eslint-disable-next-line no-unused-vars,import/no-extraneous-dependencies
import tinymce from 'tinymce/tinymce';
Expand Down Expand Up @@ -45,10 +45,11 @@ import contentUiCss from '!!raw-loader!tinymce/skins/ui/oxide/content.min.css';
const TinyMCEEditor = (props) => {
// note that skin and content_css is disabled to avoid the normal
// loading process and is instead loaded as a string via content_style

const location = useLocation();
const { courseId, postId } = useParams();
const [showImageWarning, setShowImageWarning] = useState(false);
const intl = useIntl();
const enableInContextSidebar = Boolean(new URLSearchParams(location.search).get('inContextSidebar') !== null);

/* istanbul ignore next */
const setup = useCallback((editor) => {
Expand Down Expand Up @@ -99,6 +100,28 @@ const TinyMCEEditor = (props) => {
contentStyle = '';
}

useEffect(() => {

Check failure on line 103 in src/components/TinyMCEEditor.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected to return a value at the end of arrow function
if (enableInContextSidebar) {
const checkToxDialogVisibility = () => {
const toxDialog = document.querySelector('.tox-dialog');
if (toxDialog && getComputedStyle(toxDialog).display !== 'none') {
toxDialog.style.alignSelf = 'start';
toxDialog.style.marginTop = '50px';
}
};

const observer = new MutationObserver(checkToxDialogVisibility);

// Observe changes to the entire document
observer.observe(document, { childList: true, subtree: true });

// Clean up the observer when the component unmounts
return () => {
observer.disconnect();
};
}
}, [enableInContextSidebar]);

return (
<>
<Editor
Expand Down

0 comments on commit 01da103

Please sign in to comment.