diff --git a/frontend/apps/remark42/app/components/auth/auth.hooks.ts b/frontend/apps/remark42/app/components/auth/auth.hooks.ts index c5e62e65..dadb1b0c 100644 --- a/frontend/apps/remark42/app/components/auth/auth.hooks.ts +++ b/frontend/apps/remark42/app/components/auth/auth.hooks.ts @@ -70,7 +70,9 @@ export function useDropdown(disableClosing?: boolean) { useEffect(() => { const dropdownElement = rootRef.current; - if (!dropdownElement) { + if (!dropdownElement || !showDropdown) { + handleChangeIframeSize(document.body); + return; } diff --git a/frontend/apps/remark42/app/components/root/root.tsx b/frontend/apps/remark42/app/components/root/root.tsx index 57fe3e10..43e2091d 100644 --- a/frontend/apps/remark42/app/components/root/root.tsx +++ b/frontend/apps/remark42/app/components/root/root.tsx @@ -122,6 +122,7 @@ export class Root extends Component { Promise.all([userloading, this.props.fetchComments()]).finally(() => { setTimeout(this.checkUrlHash); window.addEventListener('hashchange', this.checkUrlHash); + postMessageToParent({ height: document.body.offsetHeight }); }); window.addEventListener('message', this.onMessage); @@ -273,12 +274,33 @@ export class Root extends Component {
- + {!!this.props.topComments.length && !props.isCommentsLoading && ( +
+ {(IS_MOBILE && commentsShown < this.props.topComments.length + ? this.props.topComments.slice(0, commentsShown) + : this.props.topComments + ).map((id) => ( + + ))} + + {commentsShown < this.props.topComments.length && IS_MOBILE && ( + + )} +
+ )} + {props.isCommentsLoading && ( +
+ +
+ )} )} @@ -287,17 +309,21 @@ export class Root extends Component { } } +const CopyrightLink = (title: string) => ( + + {title} + +); + function updateIframeHeight() { postMessageToParent({ height: document.body.offsetHeight }); } -interface CommentsProps { - isLoading: boolean; - topComments: string[]; - commentsShown: number; - showMore(): void; -} -function Comments({ isLoading, topComments, commentsShown, showMore }: CommentsProps) { +/** Root component connected to redux */ +export function ConnectedRoot() { + const intl = useIntl(); + const props = useSelector(mapStateToProps); + const actions = useActions(boundActions); const rootRef = useRef(null); useEffect(() => { @@ -310,9 +336,7 @@ function Comments({ isLoading, topComments, commentsShown, showMore }: CommentsP updateIframeHeight(); // a hacky way to force iframe height update when new image is rendered and loaded - rootRef.current?.querySelectorAll('img').forEach((img) => { - img.addEventListener('load', updateIframeHeight); - }); + rootRef.current?.querySelectorAll('img').forEach((img) => img.addEventListener('load', updateIframeHeight)); }); observer.observe(rootRef.current, { attributes: true, childList: true, subtree: true }); @@ -320,45 +344,8 @@ function Comments({ isLoading, topComments, commentsShown, showMore }: CommentsP return () => observer.disconnect(); }, []); - const renderComments = - IS_MOBILE && commentsShown < topComments.length ? topComments.slice(0, commentsShown) : topComments; - const isShowMoreButtonVisible = IS_MOBILE && commentsShown < topComments.length; - return ( -
- {isLoading ? ( - - ) : ( - <> - {topComments.length > 0 && - renderComments.map((id) => ( - - ))} - {isShowMoreButtonVisible && ( - - )} - - )} -
- ); -} - -const CopyrightLink = (title: string) => ( - - {title} - -); - -/** Root component connected to redux */ -export function ConnectedRoot() { - const intl = useIntl(); - const props = useSelector(mapStateToProps); - const actions = useActions(boundActions); - - return ( -
+

{ { path: '/api', target: REMARK_API_BASE_URL, changeOrigin: true }, { path: '/auth', target: REMARK_API_BASE_URL, changeOrigin: true }, ], - client: { - overlay: false, - }, }; const plugins = [