Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Cleanup and error fix
  • Loading branch information
akasunil committed Nov 27, 2024
commit f1d7e1c79743a38d7e6b29752489ab3e5a16eca7
8 changes: 4 additions & 4 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ export default function CollabSidebar() {
enableComplementaryArea( 'core', 'edit-post/collab-sidebar' );
};

const AddCommentComponent = blockCommentId
? AddCommentToolbarButton
: AddCommentButton;

const { threads } = useSelect( ( select ) => {
const { getCurrentPostId } = select( editorStore );
const _postId = getCurrentPostId();
Expand Down Expand Up @@ -294,6 +290,10 @@ export default function CollabSidebar() {
return null; // or maybe return some message indicating no threads are available.
}

const AddCommentComponent = blockCommentId
? AddCommentToolbarButton
: AddCommentButton;

return (
<>
<AddCommentComponent onClick={ openCollabBoard } />
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/collab-sidebar/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export function getEditorCanvasBackgroundColor() {
const iframe = document.querySelector( 'iframe[name="editor-canvas"]' );
const iframeDocument =
iframe?.contentDocument || iframe?.contentWindow.document;
const iframeBody = iframeDocument?.querySelector( 'body' );
const iframeBody = iframeDocument?.body;
if ( iframeBody ) {
const style = window.getComputedStyle( iframeBody );
return style.backgroundColor;
return style?.backgroundColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we can just get the colour from global styles, but I guess this is fine for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve updated the implementation to pull the color directly from the global styles., and also kept this function for fallback background color.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove it for now, and reduce complexity. There's also cases where the editor doesn't have an iframe, so this code is too fragile atm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I'll remove the fallback function for now. However, we might still encounter cases where global styles aren't supported, should we consider that later?

}

return '';
Expand Down
Loading