Skip to content
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
6 changes: 3 additions & 3 deletions packages/core/src/extensions/Comments/CommentsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class CommentsPlugin extends BlockNoteExtension {
);

const threadId = commentMark?.attrs.threadId as string | undefined;
self.selectThread(threadId, false);
self.selectThread(threadId);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the second param? Why is it removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You could set it to false to prevent scrolling to the mark (scrollToThread). We did this before and handled the scrolling in the Card component instead. Turns out. this was the only place it was set so I removed it outright.

},
},
}),
Expand All @@ -268,7 +268,7 @@ export class CommentsPlugin extends BlockNoteExtension {
/**
* Set the selected thread
*/
public selectThread(threadId: string | undefined, scrollToThread = true) {
public selectThread(threadId: string | undefined) {
if (this.selectedThreadId === threadId) {
return;
}
Expand All @@ -280,7 +280,7 @@ export class CommentsPlugin extends BlockNoteExtension {
}),
);

if (threadId && scrollToThread) {
if (threadId) {
const selectedThreadPosition = this.threadPositions.get(threadId);

if (!selectedThreadPosition) {
Expand Down
17 changes: 3 additions & 14 deletions packages/mantine/src/comments/Card.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

Always happy to remove an effect!

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { assertEmpty, mergeCSSClasses } from "@blocknote/core";
import { ComponentProps, mergeRefs } from "@blocknote/react";
import { ComponentProps } from "@blocknote/react";
import {
Card as MantineCard,
Divider as MantineDivider,
Text as MantineText,
} from "@mantine/core";
import { forwardRef, useEffect, useRef } from "react";
import { forwardRef } from "react";

export const Card = forwardRef<
HTMLDivElement,
Expand All @@ -24,24 +24,13 @@ export const Card = forwardRef<

assertEmpty(rest, false);

// Makes the card scroll into view when selected.
const scrollRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (selected) {
scrollRef.current?.scrollIntoView({
behavior: "smooth",
block: "center",
});
}
}, [selected]);

return (
<MantineCard
className={mergeCSSClasses(className, selected ? "selected" : "")}
onFocus={onFocus}
onBlur={onBlur}
tabIndex={tabIndex}
ref={mergeRefs([ref, scrollRef])}
ref={ref}
>
{headerText && (
<MantineText className={"bn-header-text"}>{headerText}</MantineText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
InlineContentSchema,
StyleSchema,
} from "@blocknote/core";
import { UseFloatingOptions, flip, offset, shift } from "@floating-ui/react";
import {
UseFloatingOptions,
autoUpdate,
flip,
offset,
shift,
} from "@floating-ui/react";
import {
ComponentProps,
FC,
Expand Down Expand Up @@ -55,6 +61,7 @@ export const FloatingThreadController = <
editor.focus();
}
},
whileElementsMounted: autoUpdate,
...props.floatingOptions,
});

Expand Down
Loading