Fix pipeline bug on scroll (#666)

* Fix pipeline bug on scroll

* Fix lint

* Fix lint
This commit is contained in:
Charles Bochet
2023-07-15 11:00:32 -07:00
committed by GitHub
parent efd4ed16d6
commit 2bbcf6980a
8 changed files with 29 additions and 27 deletions

View File

@ -5001,7 +5001,7 @@ export type GetPipelinesLazyQueryHookResult = ReturnType<typeof useGetPipelinesL
export type GetPipelinesQueryResult = Apollo.QueryResult<GetPipelinesQuery, GetPipelinesQueryVariables>; export type GetPipelinesQueryResult = Apollo.QueryResult<GetPipelinesQuery, GetPipelinesQueryVariables>;
export const GetPipelineProgressDocument = gql` export const GetPipelineProgressDocument = gql`
query GetPipelineProgress($where: PipelineProgressWhereInput) { query GetPipelineProgress($where: PipelineProgressWhereInput) {
findManyPipelineProgress(where: $where) { findManyPipelineProgress(where: $where, orderBy: {createdAt: asc}) {
id id
progressableType progressableType
progressableId progressableId

View File

@ -1,4 +1,4 @@
import { useCallback, useRef, useState } from 'react'; import { useCallback, useState } from 'react';
import { getOperationName } from '@apollo/client/utilities'; import { getOperationName } from '@apollo/client/utilities';
import { useRecoilState } from 'recoil'; import { useRecoilState } from 'recoil';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@ -26,7 +26,6 @@ import {
import { currentPipelineState } from '~/pages/opportunities/currentPipelineState'; import { currentPipelineState } from '~/pages/opportunities/currentPipelineState';
export function NewCompanyProgressButton() { export function NewCompanyProgressButton() {
const containerRef = useRef<HTMLDivElement>(null);
const [isCreatingCard, setIsCreatingCard] = useState(false); const [isCreatingCard, setIsCreatingCard] = useState(false);
const [board, setBoard] = useRecoilState(boardState); const [board, setBoard] = useRecoilState(boardState);
const [pipeline] = useRecoilState(currentPipelineState); const [pipeline] = useRecoilState(currentPipelineState);
@ -112,24 +111,22 @@ export function NewCompanyProgressButton() {
return ( return (
<> <>
{isCreatingCard && ( {isCreatingCard ? (
<RecoilScope> <RecoilScope>
<div ref={containerRef}> <SingleEntitySelect
<div ref={containerRef}> onEntitySelected={(value) => handleEntitySelect(value)}
<SingleEntitySelect onCancel={handleCancel}
onEntitySelected={(value) => handleEntitySelect(value)} entities={{
onCancel={handleCancel} entitiesToSelect: companies.entitiesToSelect,
entities={{ selectedEntity: companies.selectedEntities[0],
entitiesToSelect: companies.entitiesToSelect, loading: companies.loading,
selectedEntity: companies.selectedEntities[0], }}
loading: companies.loading, disableBackgroundBlur={true}
}} />
/>
</div>
</div>
</RecoilScope> </RecoilScope>
) : (
<NewButton onClick={handleNewClick} />
)} )}
<NewButton onClick={handleNewClick} />
</> </>
); );
} }

View File

@ -18,6 +18,10 @@ const StyledPlaceholder = styled.div`
min-height: 1px; min-height: 1px;
`; `;
const StyledNewCardButtonContainer = styled.div`
padding-bottom: ${({ theme }) => theme.spacing(40)};
`;
const BoardColumnCardsContainer = ({ const BoardColumnCardsContainer = ({
children, children,
droppableProvided, droppableProvided,
@ -72,7 +76,9 @@ export function EntityBoardColumn({
</RecoilScope> </RecoilScope>
))} ))}
</BoardColumnCardsContainer> </BoardColumnCardsContainer>
<RecoilScope>{boardOptions.newCardComponent}</RecoilScope> <StyledNewCardButtonContainer>
<RecoilScope>{boardOptions.newCardComponent}</RecoilScope>
</StyledNewCardButtonContainer>
</BoardColumn> </BoardColumn>
)} )}
</Droppable> </Droppable>

View File

@ -21,7 +21,7 @@ export const GET_PIPELINES = gql`
export const GET_PIPELINE_PROGRESS = gql` export const GET_PIPELINE_PROGRESS = gql`
query GetPipelineProgress($where: PipelineProgressWhereInput) { query GetPipelineProgress($where: PipelineProgressWhereInput) {
findManyPipelineProgress(where: $where) { findManyPipelineProgress(where: $where, orderBy: { createdAt: asc }) {
id id
progressableType progressableType
progressableId progressableId

View File

@ -30,11 +30,13 @@ export function SingleEntitySelect<
onEntitySelected, onEntitySelected,
onCreate, onCreate,
onCancel, onCancel,
disableBackgroundBlur = false,
}: { }: {
onCancel?: () => void; onCancel?: () => void;
onCreate?: () => void; onCreate?: () => void;
entities: EntitiesForSingleEntitySelect<CustomEntityForSelect>; entities: EntitiesForSingleEntitySelect<CustomEntityForSelect>;
onEntitySelected: (entity: CustomEntityForSelect) => void; onEntitySelected: (entity: CustomEntityForSelect) => void;
disableBackgroundBlur?: boolean;
}) { }) {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
@ -49,7 +51,7 @@ export function SingleEntitySelect<
}); });
return ( return (
<DropdownMenu ref={containerRef}> <DropdownMenu disableBlur={disableBackgroundBlur} ref={containerRef}>
<DropdownMenuSearch <DropdownMenuSearch
value={searchFilter} value={searchFilter}
onChange={handleSearchFilterChange} onChange={handleSearchFilterChange}

View File

@ -5,7 +5,6 @@ export const StyledBoard = styled.div`
border-radius: ${({ theme }) => theme.spacing(2)}; border-radius: ${({ theme }) => theme.spacing(2)};
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: calc(100%);
overflow-x: auto; overflow-x: auto;
width: 100%; width: 100%;
`; `;

View File

@ -13,7 +13,6 @@ const StyledButton = styled.button`
cursor: pointer; cursor: pointer;
display: flex; display: flex;
gap: ${({ theme }) => theme.spacing(1)}; gap: ${({ theme }) => theme.spacing(1)};
justify-content: center;
padding: ${({ theme }) => theme.spacing(1)}; padding: ${({ theme }) => theme.spacing(1)};
&:hover { &:hover {

View File

@ -1,8 +1,9 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
export const DropdownMenu = styled.div` export const DropdownMenu = styled.div<{ disableBlur?: boolean }>`
align-items: center; align-items: center;
backdrop-filter: blur(20px); backdrop-filter: ${({ disableBlur }) =>
disableBlur ? 'none' : 'blur(20px)'};
background: ${({ theme }) => theme.background.transparent.secondary}; background: ${({ theme }) => theme.background.transparent.secondary};
border: 1px solid ${({ theme }) => theme.border.color.light}; border: 1px solid ${({ theme }) => theme.border.color.light};
@ -14,7 +15,5 @@ export const DropdownMenu = styled.div`
flex-direction: column; flex-direction: column;
height: fit-content;
width: 200px; width: 200px;
`; `;