fix: Formatting toolbar clipped on first comment in sidebar, closes #6841
This commit is contained in:
@@ -10,11 +10,20 @@ type Props = React.HTMLAttributes<HTMLDivElement> & {
|
|||||||
bottomShadow?: boolean;
|
bottomShadow?: boolean;
|
||||||
hiddenScrollbars?: boolean;
|
hiddenScrollbars?: boolean;
|
||||||
flex?: boolean;
|
flex?: boolean;
|
||||||
|
overflow?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
function Scrollable(
|
function Scrollable(
|
||||||
{ shadow, topShadow, bottomShadow, hiddenScrollbars, flex, ...rest }: Props,
|
{
|
||||||
|
shadow,
|
||||||
|
topShadow,
|
||||||
|
bottomShadow,
|
||||||
|
hiddenScrollbars,
|
||||||
|
flex,
|
||||||
|
overflow,
|
||||||
|
...rest
|
||||||
|
}: Props,
|
||||||
ref: React.RefObject<HTMLDivElement>
|
ref: React.RefObject<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
const fallbackRef = React.useRef<HTMLDivElement>();
|
const fallbackRef = React.useRef<HTMLDivElement>();
|
||||||
@@ -60,6 +69,7 @@ function Scrollable(
|
|||||||
$hiddenScrollbars={hiddenScrollbars}
|
$hiddenScrollbars={hiddenScrollbars}
|
||||||
$topShadowVisible={topShadowVisible}
|
$topShadowVisible={topShadowVisible}
|
||||||
$bottomShadowVisible={bottomShadowVisible}
|
$bottomShadowVisible={bottomShadowVisible}
|
||||||
|
$overflow={overflow}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -70,12 +80,13 @@ const Wrapper = styled.div<{
|
|||||||
$topShadowVisible?: boolean;
|
$topShadowVisible?: boolean;
|
||||||
$bottomShadowVisible?: boolean;
|
$bottomShadowVisible?: boolean;
|
||||||
$hiddenScrollbars?: boolean;
|
$hiddenScrollbars?: boolean;
|
||||||
|
$overflow?: string;
|
||||||
}>`
|
}>`
|
||||||
display: ${(props) => (props.$flex ? "flex" : "block")};
|
display: ${(props) => (props.$flex ? "flex" : "block")};
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: ${(props) => (props.$overflow ? props.$overflow : "auto")};
|
||||||
overflow-x: hidden;
|
overflow-x: ${(props) => (props.$overflow ? props.$overflow : "hidden")};
|
||||||
overscroll-behavior: none;
|
overscroll-behavior: none;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
box-shadow: ${(props) => {
|
box-shadow: ${(props) => {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ function Comments() {
|
|||||||
.threadsInDocument(document.id)
|
.threadsInDocument(document.id)
|
||||||
.filter((thread) => !thread.isNew || thread.createdById === user.id);
|
.filter((thread) => !thread.isNew || thread.createdById === user.id);
|
||||||
const hasComments = threads.length > 0;
|
const hasComments = threads.length > 0;
|
||||||
|
const hasMultipleComments = comments.inDocument(document.id).length > 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar
|
<Sidebar
|
||||||
@@ -50,8 +51,9 @@ function Comments() {
|
|||||||
scrollable={false}
|
scrollable={false}
|
||||||
>
|
>
|
||||||
<Scrollable
|
<Scrollable
|
||||||
bottomShadow={!focusedComment}
|
|
||||||
id="comments"
|
id="comments"
|
||||||
|
overflow={hasMultipleComments ? undefined : "initial"}
|
||||||
|
bottomShadow={!focusedComment}
|
||||||
hiddenScrollbars
|
hiddenScrollbars
|
||||||
topShadow
|
topShadow
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ export default class CommentsStore extends Store<Comment> {
|
|||||||
super(rootStore, Comment);
|
super(rootStore, Comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of comments in a document.
|
||||||
|
*
|
||||||
|
* @param documentId ID of the document to get comments for
|
||||||
|
* @returns Array of comments
|
||||||
|
*/
|
||||||
|
inDocument(documentId: string): Comment[] {
|
||||||
|
return this.filter((comment: Comment) => comment.documentId === documentId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of comments in a document that are not replies to other
|
* Returns a list of comments in a document that are not replies to other
|
||||||
* comments.
|
* comments.
|
||||||
|
|||||||
Reference in New Issue
Block a user