Skip to content

Commit

Permalink
fix(releases): hiding the calendar in type picker when not scheduled …
Browse files Browse the repository at this point in the history
…type
  • Loading branch information
jordanl17 committed Dec 24, 2024
1 parent d6c6663 commit 07b263f
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ export function ReleaseTypePicker(props: {release: ReleaseDocument}): JSX.Elemen
}, [inputValue, isPublishDateInPast, publishDate, release.publishAt, releaseType, t, tRelease])

const handleButtonReleaseTypeChange = useCallback((pickedReleaseType: ReleaseType) => {
if (pickedReleaseType === 'scheduled') {
setDateInputOpen(true)
}
setDateInputOpen(pickedReleaseType === 'scheduled')

setReleaseType(pickedReleaseType)
const nextPublishAt = pickedReleaseType === 'scheduled' ? new Date() : undefined
Expand All @@ -136,6 +134,11 @@ export function ReleaseTypePicker(props: {release: ReleaseDocument}): JSX.Elemen
}
}, [])

const handleOnPickerClick = () => {
if (open) close()
else setOpen(true)
}

const PopoverContent = () => {
return (
<Stack space={1}>
Expand Down Expand Up @@ -199,7 +202,7 @@ export function ReleaseTypePicker(props: {release: ReleaseDocument}): JSX.Elemen
isReleaseScheduled || release.state === 'archived' || release.state === 'published'
}
mode="bleed"
onClick={() => setOpen(!open)}
onClick={handleOnPickerClick}
padding={2}
ref={buttonRef}
tooltipProps={{
Expand All @@ -209,10 +212,11 @@ export function ReleaseTypePicker(props: {release: ReleaseDocument}): JSX.Elemen
selected={open}
tone={getReleaseTone({...release, metadata: {...release.metadata, releaseType}})}
style={{borderRadius: '999px'}}
data-testid="release-type-picker"
>
<Flex flex={1} gap={2}>
{isUpdating ? (
<Spinner size={1} />
<Spinner size={1} data-testid="updating-release-spinner" />
) : (
<ReleaseAvatar
tone={getReleaseTone({...release, metadata: {...release.metadata, releaseType}})}
Expand Down

0 comments on commit 07b263f

Please sign in to comment.