@@ -71,6 +71,7 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
7171 const { collector } = useQueryResultChange ( ) ;
7272 const { cellManager } = useTableCellManager ( ) ;
7373 const { schema, currentDatabase } = useSchmea ( ) ;
74+ const [ isGridCSSPrepared , setGridCSSPrepared ] = useState ( false ) ;
7475
7576 const { handleContextMenu } = useContextMenu ( ( ) => {
7677 return [
@@ -104,8 +105,9 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
104105 if ( tableRef . current ) {
105106 tableRef . current . style . gridTemplateColumns =
106107 result ?. headers . map ( ( ) => '150px' ) . join ( ' ' ) || '' ;
108+ setGridCSSPrepared ( true ) ;
107109 }
108- } , [ result , tableRef ] ) ;
110+ } , [ result , tableRef , setGridCSSPrepared ] ) ;
109111
110112 if ( ! result ?. headers || ! result ?. rows ) {
111113 return < div > No result</ div > ;
@@ -146,25 +148,31 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
146148 onContextMenu = { handleContextMenu }
147149 >
148150 < table ref = { tableRef } className = { styles . table } >
149- < thead >
150- < tr >
151- { result . headers . map ( ( header , idx ) => (
152- < th key = { header . name } >
153- < div className = { styles . headerContent } >
154- < div className = { styles . headerContentTitle } > { header . name } </ div >
155- { ! ! header ?. schema ?. primaryKey && (
156- < div className = { styles . headerContentIcon } >
157- < Icon . GreenKey />
151+ { isGridCSSPrepared && (
152+ < >
153+ < thead >
154+ < tr >
155+ { result . headers . map ( ( header , idx ) => (
156+ < th key = { header . name } >
157+ < div className = { styles . headerContent } >
158+ < div className = { styles . headerContentTitle } >
159+ { header . name }
160+ </ div >
161+ { ! ! header ?. schema ?. primaryKey && (
162+ < div className = { styles . headerContentIcon } >
163+ < Icon . GreenKey />
164+ </ div >
165+ ) }
158166 </ div >
159- ) }
160- </ div >
161- < ResizeHandler idx = { idx } />
162- </ th >
163- ) ) }
164- </ tr >
165- </ thead >
166-
167- < tbody > { RowList } </ tbody >
167+ < ResizeHandler idx = { idx } />
168+ </ th >
169+ ) ) }
170+ </ tr >
171+ </ thead >
172+
173+ < tbody > { RowList } </ tbody >
174+ </ >
175+ ) }
168176 </ table >
169177 </ div >
170178 ) ;
0 commit comments