From 20f3c55914791c9d5e5d3eff6e198bb11a4b7e21 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 30 Apr 2023 15:42:05 -0400 Subject: [PATCH] Various sidebar fixes (#5278 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Right sidebar depth Re-arrange order of document metadata * fix: Comment reply not focused on 'Reply…' tap * fix: Sidebar animation oddities on mobile/Safari --- app/components/Sidebar/Right.tsx | 10 +++---- .../Document/components/CommentForm.tsx | 3 -- .../Document/components/CommentThread.tsx | 4 +-- .../Document/components/DocumentMeta.tsx | 28 +++++++++---------- shared/i18n/locales/en_US/translation.json | 4 +-- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/app/components/Sidebar/Right.tsx b/app/components/Sidebar/Right.tsx index 3d4c7b616..c3171120a 100644 --- a/app/components/Sidebar/Right.tsx +++ b/app/components/Sidebar/Right.tsx @@ -69,7 +69,7 @@ function Right({ children, border, className }: Props) { const style = React.useMemo( () => isMobile - ? { width: "80%" } + ? { width: "80vw" } : { width: `${ui.sidebarRightWidth}px`, }, @@ -112,9 +112,10 @@ function Right({ children, border, className }: Props) { } const Position = styled(Flex)` - position: fixed; + position: absolute; top: 0; bottom: 0; + left: 0; `; const Sidebar = styled(m.div)<{ @@ -123,17 +124,16 @@ const Sidebar = styled(m.div)<{ display: flex; flex-shrink: 0; background: ${s("background")}; - max-width: 80%; + max-width: 80vw; border-left: 1px solid ${s("divider")}; transition: border-left 100ms ease-in-out; - z-index: 1; + z-index: ${depths.sidebar}; ${breakpoint("mobile", "tablet")` position: absolute; top: 0; right: 0; bottom: 0; - z-index: ${depths.sidebar}; `} ${breakpoint("tablet")` diff --git a/app/scenes/Document/components/CommentForm.tsx b/app/scenes/Document/components/CommentForm.tsx index 44589b5c8..70dfb4649 100644 --- a/app/scenes/Document/components/CommentForm.tsx +++ b/app/scenes/Document/components/CommentForm.tsx @@ -40,8 +40,6 @@ type Props = { onFocus?: () => void; /** Callback when the editor is blurred */ onBlur?: () => void; - /** Callback when the editor is clicked outside of */ - onClickOutside?: (event: MouseEvent | TouchEvent) => void; }; function CommentForm({ @@ -50,7 +48,6 @@ function CommentForm({ onTyping, onFocus, onBlur, - onClickOutside, autoFocus, standalone, placeholder, diff --git a/app/scenes/Document/components/CommentThread.tsx b/app/scenes/Document/components/CommentThread.tsx index 21b28ab1d..82bb744e0 100644 --- a/app/scenes/Document/components/CommentThread.tsx +++ b/app/scenes/Document/components/CommentThread.tsx @@ -143,7 +143,7 @@ function CommentThread({ $focused={focused} $recessed={recessed} $dir={document.dir} - onClick={handleClickThread} + onPointerUp={handleClickThread} > {commentsInThread.map((comment, index) => { const firstOfAuthor = @@ -192,7 +192,7 @@ function CommentThread({ )} {!focused && !recessed && can.comment && ( - setAutoFocus(true)}>{t("Reply")}… + setAutoFocus(true)}>{t("Reply")}… )} ); diff --git a/app/scenes/Document/components/DocumentMeta.tsx b/app/scenes/Document/components/DocumentMeta.tsx index f535fd809..e354a2d97 100644 --- a/app/scenes/Document/components/DocumentMeta.tsx +++ b/app/scenes/Document/components/DocumentMeta.tsx @@ -37,6 +37,20 @@ function TitleDocumentMeta({ to, isDraft, document, ...rest }: Props) { return ( + {team?.getPreference(TeamPreference.Commenting) && ( + <> +  •  + ui.toggleComments(document.id)} + > + + {commentsCount + ? t("{{ count }} comment", { count: commentsCount }) + : t("Comment")} + + + )} {totalViewers && !isDraft ? (  •  @@ -54,20 +68,6 @@ function TitleDocumentMeta({ to, isDraft, document, ...rest }: Props) { ) : null} - {team?.getPreference(TeamPreference.Commenting) && ( - <> -  •  - ui.toggleComments(document.id)} - > - - {commentsCount - ? t("{{ count }} comment", { count: commentsCount }) - : t("Comment")} - - - )} ); } diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index ba6b0ab45..88f47bb86 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -452,12 +452,12 @@ "Error updating comment": "Error updating comment", "edited": "edited", "Images are still uploading.\nAre you sure you want to discard them?": "Images are still uploading.\nAre you sure you want to discard them?", + "{{ count }} comment": "{{ count }} comment", + "{{ count }} comment_plural": "{{ count }} comments", "Viewed by": "Viewed by", "only you": "only you", "person": "person", "people": "people", - "{{ count }} comment": "{{ count }} comment", - "{{ count }} comment_plural": "{{ count }} comments", "Type '/' to insert, or start writing…": "Type '/' to insert, or start writing…", "Hide contents": "Hide contents", "Show contents": "Show contents",