File tree Expand file tree Collapse file tree 8 files changed +23
-18
lines changed
ContainerWidget/TabWidget Expand file tree Collapse file tree 8 files changed +23
-18
lines changed Original file line number Diff line number Diff line change 1616 * limitations under the License.
1717 */
1818
19- import { useEffect , useState } from 'react' ;
19+ import { useLayoutEffect , useState } from 'react' ;
2020import useResizeObserver from './useResizeObserver' ;
2121
2222export const useCacheWidthHeight = (
@@ -33,7 +33,7 @@ export const useCacheWidthHeight = (
3333 refreshMode : 'debounce' ,
3434 refreshRate : 20 ,
3535 } ) ;
36- useEffect ( ( ) => {
36+ useLayoutEffect ( ( ) => {
3737 if ( width > 0 ) {
3838 setCacheW ( width ) ;
3939 setCacheH ( height ) ;
Original file line number Diff line number Diff line change @@ -21,11 +21,18 @@ import {
2121 BASE_VIEW_WIDTH ,
2222 MIN_ROW_HEIGHT ,
2323} from 'app/pages/DashBoardPage/constants' ;
24- import { useMemo } from 'react' ;
25- import { useCacheWidthHeight } from './useCacheWidthHeight ' ;
24+ import { useLayoutEffect , useMemo , useState } from 'react' ;
25+ import useResizeObserver from './useResizeObserver ' ;
2626
2727export const useWidgetRowHeight = ( ) => {
28- const { ref, cacheW } = useCacheWidthHeight ( ) ;
28+ const [ cacheW , setCacheW ] = useState ( 0 ) ;
29+ const { ref, width = 0 } = useResizeObserver < HTMLDivElement > ( ) ;
30+
31+ useLayoutEffect ( ( ) => {
32+ if ( width > 0 ) {
33+ setCacheW ( width ) ;
34+ }
35+ } , [ width ] ) ;
2936 const widgetRowHeight = useMemo ( ( ) => {
3037 let dynamicHeight = ( cacheW * BASE_ROW_HEIGHT ) / BASE_VIEW_WIDTH ;
3138 return Math . max ( dynamicHeight , MIN_ROW_HEIGHT ) ;
Original file line number Diff line number Diff line change @@ -43,15 +43,14 @@ export const QueryWidget: React.FC<CompProps> = () => {
4343} ;
4444
4545const Wrap = styled . div < FontConfig & { background : string } > `
46- cursor: pointer;
47- flex: 1;
4846 display: flex;
47+ flex: 1;
4948 align-items: center;
5049 justify-content: center;
5150 font: ${ p =>
5251 `${ p . fontStyle } ${ p . fontWeight } ${ p . fontSize } px ${ p . fontFamily } ` } ;
5352 color: ${ p => p . color } ;
54-
53+ cursor: pointer;
5554 &:hover {
5655 background: ${ p =>
5756 getLuminance ( p . background ) > 0.5
Original file line number Diff line number Diff line change @@ -43,15 +43,14 @@ export const ResetWidget: React.FC<CompProps> = () => {
4343} ;
4444
4545const Wrap = styled . div < FontConfig & { background : string } > `
46- cursor: pointer;
47- flex: 1;
4846 display: flex;
47+ flex: 1;
4948 align-items: center;
5049 justify-content: center;
5150 font: ${ p =>
5251 `${ p . fontStyle } ${ p . fontWeight } ${ p . fontSize } px ${ p . fontFamily } ` } ;
5352 color: ${ p => p . color } ;
54-
53+ cursor: pointer;
5554 &:hover {
5655 background: ${ p =>
5756 getLuminance ( p . background ) > 0.5
Original file line number Diff line number Diff line change @@ -84,10 +84,10 @@ interface WrapProps {
8484const Wrap = styled . div < WrapProps > `
8585 position: relative;
8686 box-sizing: border-box;
87- width: 100%;
88- height: 100%;
8987 display: flex;
9088 flex: 1;
89+ width: 100%;
90+ height: 100%;
9191 border: ${ p => p . border } ;
9292
9393 & .widget-tool-bar {
@@ -104,8 +104,8 @@ const Wrap = styled.div<WrapProps>`
104104` ;
105105const ItemContainer = styled . div `
106106 position: absolute;
107- display: flex;
108107 z-index: 10;
108+ display: flex;
109109 width: 100%;
110110 height: 100%;
111111` ;
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ const ChartFrameBox = styled.div`
171171 overflow: hidden;
172172` ;
173173const Wrap = styled . div `
174+ position: relative;
174175 display: flex;
175176 flex: 1;
176- position: relative;
177177` ;
Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ const StyledContainer = styled(StyledBackground)`
310310 .empty {
311311 display: flex;
312312 flex: 1;
313- justify-content: center;
314313 align-items: center;
314+ justify-content: center;
315315 }
316316` ;
Original file line number Diff line number Diff line change @@ -134,11 +134,11 @@ const Wrap = styled.div`
134134 overflow-y: hidden;
135135
136136 .empty {
137- height: 100%;
138137 display: flex;
139138 flex: 1;
140- justify-content: center;
141139 align-items: center;
140+ justify-content: center;
141+ height: 100%;
142142 }
143143 }
144144 .grid-background::-webkit-scrollbar {
You can’t perform that action at this time.
0 commit comments