Skip to content

Commit

Permalink
Merge pull request #4743 from ParabolInc/prevent-drawer-transition
Browse files Browse the repository at this point in the history
Prevent Poker drawer from jumping up
  • Loading branch information
mattkrick authored Mar 15, 2021
2 parents f6508f4 + ea943e7 commit 1af3a3d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
15 changes: 10 additions & 5 deletions packages/client/components/DiscussionThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,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
}
})
Expand Down Expand Up @@ -55,9 +54,15 @@ const DiscussionThread = (props: Props) => {
const listRef = useRef<HTMLDivElement>(null)
const editorRef = useRef<HTMLTextAreaElement>(null)
const ref = useRef<HTMLDivElement>(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(
'threads',
ref,
MeetingControlBarEnum.HEIGHT,
meetingContentRef,
undefined,
meetingType
) || !!endedAt
return (
<Wrapper isExpanded={isExpanded} isPokerMeeting={isPokerMeeting} ref={ref}>
<DiscussionThreadList
Expand Down
22 changes: 6 additions & 16 deletions packages/client/components/EstimatePhaseDiscussionDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import styled from '@emotion/styled'
import React, {RefObject, useRef} from 'react'
import React from 'react'
import graphql from 'babel-plugin-relay/macro'
import {createFragmentContainer} from 'react-relay'
import {useCoverable} from '~/hooks/useControlBarCovers'
import {desktopSidebarShadow} from '~/styles/elevation'
import {EstimatePhaseDiscussionDrawer_meeting} from '~/__generated__/EstimatePhaseDiscussionDrawer_meeting.graphql'
import {BezierCurve, DiscussionThreadEnum, MeetingControlBarEnum, ZIndex} from '../types/constEnums'
import {BezierCurve, DiscussionThreadEnum, ZIndex} from '../types/constEnums'
import DiscussionThreadRoot from './DiscussionThreadRoot'
import {PALETTE} from '~/styles/paletteV2'
import LabelHeading from './LabelHeading/LabelHeading'
Expand Down Expand Up @@ -77,32 +76,23 @@ interface Props {
isOpen: boolean
meeting: EstimatePhaseDiscussionDrawer_meeting
onToggle: () => void
meetingContentRef: RefObject<HTMLDivElement>
}

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<HTMLDivElement>(null)
const meetingControlBarBottom = 16
const coverableHeight = isDesktop ? MeetingControlBarEnum.HEIGHT + meetingControlBarBottom : 0
useCoverable('drawer', ref, coverableHeight, meetingContentRef) || !!endedAt

return (
<Drawer isDesktop={isDesktop} isOpen={isOpen} ref={ref}>
<Drawer isDesktop={isDesktop} isOpen={isOpen}>
<Header>
<HeaderLabel>{'Discussion'}</HeaderLabel>
<StyledCloseButton onClick={onToggle}>
<CloseIcon>close</CloseIcon>
</StyledCloseButton>
</Header>
<ThreadColumn>
<DiscussionThreadRoot
meetingId={meetingId}
threadSourceId={serviceTaskId!}
meetingContentRef={ref}
/>
<DiscussionThreadRoot meetingId={meetingId} threadSourceId={serviceTaskId!} />
</ThreadColumn>
</Drawer>
)
Expand Down
6 changes: 2 additions & 4 deletions packages/client/components/PokerEstimatePhase.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -44,11 +44,10 @@ const PokerEstimatePhase = (props: Props) => {
} = meeting
const isDesktop = useBreakpoint(Breakpoint.SIDEBAR_LEFT)
const toggleDrawer = useRightDrawer(meetingId)
const meetingContentRef = useRef<HTMLDivElement>(null)
if (!localStage) return null
const {service} = localStage
return (
<MeetingContent ref={meetingContentRef}>
<MeetingContent>
<StyledMeetingHeaderAndPhase isOpen={isRightDrawerOpen} hideBottomBar={!!endedAt}>
<MeetingTopBar
avatarGroup={avatarGroup}
Expand All @@ -72,7 +71,6 @@ const PokerEstimatePhase = (props: Props) => {
isDesktop={isDesktop}
isOpen={isRightDrawerOpen}
meeting={meeting}
meetingContentRef={meetingContentRef}
onToggle={toggleDrawer}
/>
</ResponsiveDashSidebar>
Expand Down
6 changes: 5 additions & 1 deletion packages/client/hooks/useControlBarCovers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {RefObject, useEffect} from 'react'
import {BezierCurve, Breakpoint, DiscussionThreadEnum, NavSidebar} from '~/types/constEnums'
import {MeetingTypeEnum} from '../__generated__/SummarySheet_meeting.graphql'
import useResizeObserver from './useResizeObserver'

interface ControlBarCoverable {
Expand Down Expand Up @@ -40,9 +41,11 @@ export const useCoverable = (
ref: RefObject<HTMLDivElement>,
height: number,
parentRef?: RefObject<HTMLDivElement>,
columnsRef?: RefObject<HTMLDivElement>
columnsRef?: RefObject<HTMLDivElement>,
meetingType?: MeetingTypeEnum
) => {
const updateCoverables = () => {
if (meetingType === 'poker') return
const el = ref.current
if (!el) return
if (window.innerWidth < Breakpoint.SINGLE_REFLECTION_COLUMN) return
Expand Down Expand Up @@ -78,6 +81,7 @@ export const useCoverable = (
}
}, [])

if (meetingType === 'poker') return true
return coverables[id]?.isExpanded ?? false
}

Expand Down

0 comments on commit 1af3a3d

Please sign in to comment.