Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: take legend-key into account when computing pagination max-width #444

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Visualization/Visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const Visualization = ({
const visualization = useMemo(() => AO && transformVisualization(AO), [AO])

const visualizationRef = useRef(visualization)
const legendKeyRef = useRef(null)

const containerCallbackRef = useCallback((node) => {
if (node === null) {
Expand All @@ -139,8 +140,12 @@ export const Visualization = ({
const containerInnerWidth = node.clientWidth
const scrollBox = node.querySelector('.tablescrollbox')
const scrollbarWidth = scrollBox.offsetWidth - scrollBox.clientWidth
const legendKeyWidth =
legendKeyRef.current?.offsetWidth > 0
? legendKeyRef.current.offsetWidth + 4
: 0
const maxWidth = Math.max(
containerInnerWidth - scrollbarWidth,
containerInnerWidth - scrollbarWidth - legendKeyWidth,
PAGINATION_MIN_WIDTH
)

Expand Down Expand Up @@ -305,6 +310,7 @@ export const Visualization = ({
<div
className={styles.legendKeyScrollbox}
data-test="visualization-legend-key"
ref={legendKeyRef}
>
<LegendKey legendSets={uniqueLegendSets} />
</div>
Expand Down
Loading