From c9f6e5c80304e32f5b89a5b5982e859f8f14f612 Mon Sep 17 00:00:00 2001 From: HendrikThePendric Date: Thu, 7 Sep 2023 17:50:56 +0200 Subject: [PATCH] fix: correctly center the table spinner --- cypress/helpers/table.js | 2 +- src/components/Visualization/Visualization.js | 40 +++++++++++++++++-- .../styles/Visualization.module.css | 23 ++++++----- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/cypress/helpers/table.js b/cypress/helpers/table.js index 7d4e031e3..3fd526cec 100644 --- a/cypress/helpers/table.js +++ b/cypress/helpers/table.js @@ -20,7 +20,7 @@ export const expectTableToBeVisible = () => getLineListTable().find('tbody').should('be.visible') export const expectTableToBeUpdated = () => - cy.getBySel('line-list-loading-indicator').should(($div) => { + cy.getBySel('line-list-fetch-container').should(($div) => { const className = $div[0].className expect(className).to.not.match(/Visualization_fetching*/) diff --git a/src/components/Visualization/Visualization.js b/src/components/Visualization/Visualization.js index b56fee4a0..08a40ba6d 100644 --- a/src/components/Visualization/Visualization.js +++ b/src/components/Visualization/Visualization.js @@ -179,6 +179,30 @@ export const Visualization = ({ sortDirection, }) + const fetchContainerRef = useRef(null) + const dataTableHeadRef = useRef(null) + const dataTableFootRef = useRef(null) + const fetchIndicatorTop = useMemo(() => { + if ( + !fetching || + !fetchContainerRef?.current || + !dataTableHeadRef?.current || + !dataTableFootRef?.current + ) { + return 'calc(50% - 12px)' + } + + const containerHeight = fetchContainerRef.current.clientHeight + const headHeight = dataTableHeadRef.current.offsetHeight + const footHeight = dataTableFootRef.current.offsetHeight + // tbody height excluding the parts hidden by scrolling + const visibleBodyHeight = containerHeight - headHeight - footHeight + // 12 px is half the loader height + const top = Math.round(headHeight + visibleBodyHeight / 2 - 12) + + return `${top}px` + }, [fetching]) + // Reset page for new visualizations useEffect(() => { visualizationRef.current = visualization @@ -305,11 +329,16 @@ export const Visualization = ({ return (
+
- + {data.headers.map((header, index) => header ? ( @@ -423,7 +452,10 @@ export const Visualization = ({ ))} - + .fetchIndicator { content: ''; position: absolute; - top: calc(50% - 24px); - left: calc(50% - 24px); - width: 48px; - height: 48px; - border-width: 6px; + left: calc(50% - 12px); + width: 24px; + height: 24px; + border-width: 3px; border-style: solid; border-color: rgba(110, 122, 138, 0.15) rgba(110, 122, 138, 0.15) rgb(20, 124, 215); @@ -35,16 +37,17 @@ animation-iteration-count: infinite; animation-name: rotation; animation-timing-function: linear; + z-index: 1; } -.fetchIndicator.fetching tbody::before { +.fetchContainer.fetching tbody::before { content: ''; position: absolute; inset: 0px; background-color: rgba(255, 255, 255, 0.8); } -.fetchIndicator :global(.tablescrollbox) { +.fetchContainer :global(.tablescrollbox) { transition: max-width 200ms ease-out; }