From 458ac3aea6ad04598472b27018fea4e4fe57e954 Mon Sep 17 00:00:00 2001 From: nickoferrall Date: Wed, 3 Mar 2021 17:31:46 -0500 Subject: [PATCH 1/2] prevent poker drawer from bumping up when control bar slides --- .../client/components/DiscussionThread.tsx | 20 ++++++---------- .../EstimatePhaseDiscussionDrawer.tsx | 22 +++++------------- .../client/components/PokerEstimatePhase.tsx | 23 +++++++++++++------ packages/client/hooks/useControlBarCovers.ts | 1 + .../mutations/NavigateMeetingMutation.ts | 1 + 5 files changed, 31 insertions(+), 36 deletions(-) diff --git a/packages/client/components/DiscussionThread.tsx b/packages/client/components/DiscussionThread.tsx index 088ed4f6006..469d1f99260 100644 --- a/packages/client/components/DiscussionThread.tsx +++ b/packages/client/components/DiscussionThread.tsx @@ -1,6 +1,6 @@ import graphql from 'babel-plugin-relay/macro' -import React, {useRef, RefObject, useMemo, } from 'react' -import { createFragmentContainer} from 'react-relay' +import React, {useRef, RefObject, useMemo} from 'react' +import {createFragmentContainer} from 'react-relay' import {DiscussionThread_viewer} from '~/__generated__/DiscussionThread_viewer.graphql' import {useCoverable} from '~/hooks/useControlBarCovers' import {Breakpoint, DiscussionThreadEnum, MeetingControlBarEnum} from '~/types/constEnums' @@ -23,8 +23,7 @@ const Wrapper = styled('div')<{isExpanded: boolean; isPokerMeeting?: boolean}>( overflow: 'hidden', width: isPokerMeeting ? '100%' : 'calc(100% - 16px)', [makeMinWidthMediaQuery(Breakpoint.SIDEBAR_LEFT)]: { - height: - isExpanded || isPokerMeeting ? '100%' : `calc(100% - ${MeetingControlBarEnum.HEIGHT}px)`, + height: isExpanded ? '100%' : `calc(100% - ${MeetingControlBarEnum.HEIGHT}px)`, width: DiscussionThreadEnum.WIDTH } }) @@ -39,12 +38,7 @@ interface Props { const DiscussionThread = (props: Props) => { const {meetingContentRef, threadSourceId, viewer} = props const meeting = viewer.meeting! - const { - endedAt, - meetingType, - replyingToCommentId, - threadSource, - } = meeting + const {endedAt, meetingType, replyingToCommentId, threadSource} = meeting const thread = threadSource?.thread const commentors = threadSource?.commentors const isPokerMeeting = meetingType === MeetingTypeEnum.poker @@ -61,9 +55,9 @@ const DiscussionThread = (props: Props) => { const listRef = useRef(null) const editorRef = useRef(null) const ref = useRef(null) - // don't resize in a poker meeting as we do this in the parent - const coverableHeight = isPokerMeeting ? 0 : MeetingControlBarEnum.HEIGHT - const isExpanded = useCoverable('threads', ref, coverableHeight, meetingContentRef) || !!endedAt + const isExpanded = + useCoverable(`${meetingType}-thread`, ref, MeetingControlBarEnum.HEIGHT, meetingContentRef) || + !!endedAt return ( void - meetingContentRef: RefObject } const EstimatePhaseDiscussionDrawer = (props: Props) => { - const {isDesktop, isOpen, meeting, meetingContentRef, onToggle} = props - const {id: meetingId, endedAt, localStage} = meeting + const {isDesktop, isOpen, meeting, onToggle} = props + const {id: meetingId, localStage} = meeting const {serviceTaskId} = localStage - const ref = useRef(null) - const meetingControlBarBottom = 16 - const coverableHeight = isDesktop ? MeetingControlBarEnum.HEIGHT + meetingControlBarBottom : 0 - useCoverable('drawer', ref, coverableHeight, meetingContentRef) || !!endedAt return ( - +
{'Discussion'} @@ -98,11 +92,7 @@ const EstimatePhaseDiscussionDrawer = (props: Props) => {
- +
) diff --git a/packages/client/components/PokerEstimatePhase.tsx b/packages/client/components/PokerEstimatePhase.tsx index aaca00eaf74..90a58ec5780 100644 --- a/packages/client/components/PokerEstimatePhase.tsx +++ b/packages/client/components/PokerEstimatePhase.tsx @@ -1,5 +1,5 @@ import graphql from 'babel-plugin-relay/macro' -import React, {useRef} from 'react' +import React from 'react' import {createFragmentContainer} from 'react-relay' import {phaseLabelLookup} from '../utils/meetings/lookups' import {PokerEstimatePhase_meeting} from '../__generated__/PokerEstimatePhase_meeting.graphql' @@ -35,14 +35,20 @@ interface Props extends PokerMeetingPhaseProps { const PokerEstimatePhase = (props: Props) => { const {avatarGroup, meeting, toggleSidebar, gotoStageId} = props - const {id: meetingId, localStage, endedAt, isCommentUnread, isRightDrawerOpen, showSidebar} = meeting + const { + id: meetingId, + localStage, + endedAt, + isCommentUnread, + isRightDrawerOpen, + showSidebar + } = meeting const isDesktop = useBreakpoint(Breakpoint.SIDEBAR_LEFT) const toggleDrawer = useRightDrawer(meetingId) - const meetingContentRef = useRef(null) if (!localStage) return null const {service} = localStage return ( - + { {phaseLabelLookup.ESTIMATE} {'Estimate each story as a team'} - {service === TaskServiceEnum.jira && } - {service === TaskServiceEnum.PARABOL && } + {service === TaskServiceEnum.jira && ( + + )} + {service === TaskServiceEnum.PARABOL && ( + + )} @@ -66,7 +76,6 @@ const PokerEstimatePhase = (props: Props) => { isDesktop={isDesktop} isOpen={isRightDrawerOpen} meeting={meeting} - meetingContentRef={meetingContentRef} onToggle={toggleDrawer} /> diff --git a/packages/client/hooks/useControlBarCovers.ts b/packages/client/hooks/useControlBarCovers.ts index 282cc8f3308..b5e34936349 100644 --- a/packages/client/hooks/useControlBarCovers.ts +++ b/packages/client/hooks/useControlBarCovers.ts @@ -42,6 +42,7 @@ export const useCoverable = ( parentRef?: RefObject, columnsRef?: RefObject ) => { + if (id === 'poker-thread') return true const updateCoverables = () => { const el = ref.current if (!el) return diff --git a/packages/client/mutations/NavigateMeetingMutation.ts b/packages/client/mutations/NavigateMeetingMutation.ts index fc3ffded960..4162dcded04 100644 --- a/packages/client/mutations/NavigateMeetingMutation.ts +++ b/packages/client/mutations/NavigateMeetingMutation.ts @@ -147,6 +147,7 @@ export const navigateMeetingTeamUpdater: SharedUpdater (a.getValue('sortOrder') < b.getValue('sortOrder') ? -1 : 1)) From ea943e73e1f95cad4e953a2d9619239c25eaf860 Mon Sep 17 00:00:00 2001 From: nickoferrall Date: Mon, 15 Mar 2021 14:17:49 -0500 Subject: [PATCH 2/2] use meetingType enum in useCoverable --- packages/client/components/DiscussionThread.tsx | 10 ++++++++-- packages/client/hooks/useControlBarCovers.ts | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/client/components/DiscussionThread.tsx b/packages/client/components/DiscussionThread.tsx index 7b5e62fa4a9..1495395cea3 100644 --- a/packages/client/components/DiscussionThread.tsx +++ b/packages/client/components/DiscussionThread.tsx @@ -55,8 +55,14 @@ const DiscussionThread = (props: Props) => { const editorRef = useRef(null) const ref = useRef(null) const isExpanded = - useCoverable(`${meetingType}-thread`, ref, MeetingControlBarEnum.HEIGHT, meetingContentRef) || - !!endedAt + useCoverable( + 'threads', + ref, + MeetingControlBarEnum.HEIGHT, + meetingContentRef, + undefined, + meetingType + ) || !!endedAt return ( , height: number, parentRef?: RefObject, - columnsRef?: RefObject + columnsRef?: RefObject, + meetingType?: MeetingTypeEnum ) => { - if (id === 'poker-thread') return true const updateCoverables = () => { + if (meetingType === 'poker') return const el = ref.current if (!el) return if (window.innerWidth < Breakpoint.SINGLE_REFLECTION_COLUMN) return @@ -79,6 +81,7 @@ export const useCoverable = ( } }, []) + if (meetingType === 'poker') return true return coverables[id]?.isExpanded ?? false }