Fix UI components (#2771)
* fixes radio button's label (issue #2566) * fixes entity title double text input's width (issue #2562) * fixed checkmark placement on color scheme card * fix failing CI Docs * fixes computed node dimensions and color scheme card * fix color scheme card background * fix color scheme card background * updated color scheme card docs * Fix --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ReactNode, useEffect, useRef, useState } from 'react';
|
||||
import { ReactNode, useLayoutEffect, useRef, useState } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
type ComputeNodeDimensionsProps = {
|
||||
@ -27,18 +27,26 @@ export const ComputeNodeDimensions = ({
|
||||
| undefined
|
||||
>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
nodeWrapperRef.current &&
|
||||
setNodeDimensions({
|
||||
width: nodeWrapperRef.current.offsetWidth,
|
||||
height: nodeWrapperRef.current.offsetHeight,
|
||||
});
|
||||
}, [node]);
|
||||
useLayoutEffect(() => {
|
||||
if (!nodeWrapperRef.current) {
|
||||
return;
|
||||
}
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
if (nodeWrapperRef.current) {
|
||||
setNodeDimensions({
|
||||
width: nodeWrapperRef.current.offsetWidth,
|
||||
height: nodeWrapperRef.current.offsetHeight,
|
||||
});
|
||||
}
|
||||
});
|
||||
resizeObserver.observe(nodeWrapperRef.current);
|
||||
return () => resizeObserver.disconnect();
|
||||
}, [nodeWrapperRef]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledNodeWrapper ref={nodeWrapperRef}>{node}</StyledNodeWrapper>
|
||||
{children(nodeDimensions)}
|
||||
{nodeDimensions && children(nodeDimensions)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user