mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
force change in reference to re render the render if visible component when the order of list changes
This commit is contained in:
parent
067a19379a
commit
83b31ec109
@ -12,6 +12,7 @@ type Props = {
|
|||||||
alwaysRender?: boolean;
|
alwaysRender?: boolean;
|
||||||
placeholderChildren?: ReactNode;
|
placeholderChildren?: ReactNode;
|
||||||
pauseHeightUpdateWhileRendering?: boolean;
|
pauseHeightUpdateWhileRendering?: boolean;
|
||||||
|
changingReference?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
const RenderIfVisible: React.FC<Props> = (props) => {
|
const RenderIfVisible: React.FC<Props> = (props) => {
|
||||||
@ -26,6 +27,7 @@ const RenderIfVisible: React.FC<Props> = (props) => {
|
|||||||
alwaysRender = false,
|
alwaysRender = false,
|
||||||
placeholderChildren = null,
|
placeholderChildren = null,
|
||||||
pauseHeightUpdateWhileRendering = false,
|
pauseHeightUpdateWhileRendering = false,
|
||||||
|
changingReference,
|
||||||
} = props;
|
} = props;
|
||||||
const [shouldVisible, setShouldVisible] = useState<boolean>(alwaysRender);
|
const [shouldVisible, setShouldVisible] = useState<boolean>(alwaysRender);
|
||||||
const placeholderHeight = useRef<string>(defaultHeight);
|
const placeholderHeight = useRef<string>(defaultHeight);
|
||||||
@ -51,6 +53,7 @@ const RenderIfVisible: React.FC<Props> = (props) => {
|
|||||||
rootMargin: `${verticalOffset}% ${horizonatlOffset}% ${verticalOffset}% ${horizonatlOffset}%`,
|
rootMargin: `${verticalOffset}% ${horizonatlOffset}% ${verticalOffset}% ${horizonatlOffset}%`,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
observer.unobserve(intersectionRef.current);
|
||||||
observer.observe(intersectionRef.current);
|
observer.observe(intersectionRef.current);
|
||||||
return () => {
|
return () => {
|
||||||
if (intersectionRef.current) {
|
if (intersectionRef.current) {
|
||||||
@ -58,7 +61,7 @@ const RenderIfVisible: React.FC<Props> = (props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [root?.current, intersectionRef, children]);
|
}, [root?.current, intersectionRef, children, changingReference]);
|
||||||
|
|
||||||
//Set height after render
|
//Set height after render
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -28,6 +28,7 @@ interface IssueBlockProps {
|
|||||||
canEditProperties: (projectId: string | undefined) => boolean;
|
canEditProperties: (projectId: string | undefined) => boolean;
|
||||||
scrollableContainerRef?: MutableRefObject<HTMLDivElement | null>;
|
scrollableContainerRef?: MutableRefObject<HTMLDivElement | null>;
|
||||||
isDragStarted?: boolean;
|
isDragStarted?: boolean;
|
||||||
|
issueIds: string[]; //DO NOT REMOVE< needed to force render for virtualization
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IssueDetailsBlockProps {
|
interface IssueDetailsBlockProps {
|
||||||
@ -112,6 +113,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = memo((props) => {
|
|||||||
canEditProperties,
|
canEditProperties,
|
||||||
scrollableContainerRef,
|
scrollableContainerRef,
|
||||||
isDragStarted,
|
isDragStarted,
|
||||||
|
issueIds,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const issue = issuesMap[issueId];
|
const issue = issuesMap[issueId];
|
||||||
@ -149,6 +151,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = memo((props) => {
|
|||||||
horizonatlOffset={50}
|
horizonatlOffset={50}
|
||||||
alwaysRender={snapshot.isDragging}
|
alwaysRender={snapshot.isDragging}
|
||||||
pauseHeightUpdateWhileRendering={isDragStarted}
|
pauseHeightUpdateWhileRendering={isDragStarted}
|
||||||
|
changingReference={issueIds}
|
||||||
>
|
>
|
||||||
<KanbanIssueDetailsBlock
|
<KanbanIssueDetailsBlock
|
||||||
issue={issue}
|
issue={issue}
|
||||||
|
@ -62,6 +62,7 @@ const KanbanIssueBlocksListMemo: React.FC<IssueBlocksListProps> = (props) => {
|
|||||||
canEditProperties={canEditProperties}
|
canEditProperties={canEditProperties}
|
||||||
scrollableContainerRef={scrollableContainerRef}
|
scrollableContainerRef={scrollableContainerRef}
|
||||||
isDragStarted={isDragStarted}
|
isDragStarted={isDragStarted}
|
||||||
|
issueIds={issueIds} //passing to force render for virtualization whenever parent rerenders
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -30,6 +30,7 @@ export const IssueBlocksList: FC<Props> = (props) => {
|
|||||||
defaultHeight="3rem"
|
defaultHeight="3rem"
|
||||||
root={containerRef}
|
root={containerRef}
|
||||||
classNames={"relative border border-transparent border-b-custom-border-200 last:border-b-transparent"}
|
classNames={"relative border border-transparent border-b-custom-border-200 last:border-b-transparent"}
|
||||||
|
changingReference={issueIds}
|
||||||
>
|
>
|
||||||
<IssueBlock
|
<IssueBlock
|
||||||
issueId={issueId}
|
issueId={issueId}
|
||||||
|
@ -35,6 +35,7 @@ interface Props {
|
|||||||
issueId: string;
|
issueId: string;
|
||||||
isScrolled: MutableRefObject<boolean>;
|
isScrolled: MutableRefObject<boolean>;
|
||||||
containerRef: MutableRefObject<HTMLTableElement | null>;
|
containerRef: MutableRefObject<HTMLTableElement | null>;
|
||||||
|
issueIds: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SpreadsheetIssueRow = observer((props: Props) => {
|
export const SpreadsheetIssueRow = observer((props: Props) => {
|
||||||
@ -49,6 +50,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => {
|
|||||||
canEditProperties,
|
canEditProperties,
|
||||||
isScrolled,
|
isScrolled,
|
||||||
containerRef,
|
containerRef,
|
||||||
|
issueIds,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [isExpanded, setExpanded] = useState<boolean>(false);
|
const [isExpanded, setExpanded] = useState<boolean>(false);
|
||||||
@ -64,6 +66,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => {
|
|||||||
defaultHeight="calc(2.75rem - 1px)"
|
defaultHeight="calc(2.75rem - 1px)"
|
||||||
root={containerRef}
|
root={containerRef}
|
||||||
placeholderChildren={<td colSpan={100} className="border-b-[0.5px]" />}
|
placeholderChildren={<td colSpan={100} className="border-b-[0.5px]" />}
|
||||||
|
changingReference={issueIds}
|
||||||
>
|
>
|
||||||
<IssueRowDetails
|
<IssueRowDetails
|
||||||
issueId={issueId}
|
issueId={issueId}
|
||||||
@ -96,6 +99,7 @@ export const SpreadsheetIssueRow = observer((props: Props) => {
|
|||||||
portalElement={portalElement}
|
portalElement={portalElement}
|
||||||
isScrolled={isScrolled}
|
isScrolled={isScrolled}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
|
issueIds={issueIds}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
@ -99,6 +99,7 @@ export const SpreadsheetTable = observer((props: Props) => {
|
|||||||
portalElement={portalElement}
|
portalElement={portalElement}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
isScrolled={isScrolled}
|
isScrolled={isScrolled}
|
||||||
|
issueIds={issueIds}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user