Skip to content

Commit

Permalink
fix(protocol-designer): fix scroll on SelectPipettes screen (#16983)
Browse files Browse the repository at this point in the history
Reverts overflow on SelectPipettes screen to `OVERFLOW_SCROLL`. Also,
adds autoscroll to bottom to reveal tiprack selection if obscured.
  • Loading branch information
ncdiehl11 authored Nov 27, 2024
1 parent b82fc0e commit ff1df36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled, { css } from 'styled-components'
import { useDispatch, useSelector } from 'react-redux'
Expand Down Expand Up @@ -91,6 +91,16 @@ export function SelectPipettes(props: WizardTileProps): JSX.Element | null {
setPipetteVolume(null)
}

const ref = useRef<HTMLDivElement | null>(null)

const handleScrollToBottom = (): void => {
if (ref.current != null) {
ref.current.scrollIntoView({
behavior: 'smooth',
block: 'end',
})
}
}
// initialize pipette name once all fields are filled out
useEffect(() => {
if (
Expand All @@ -106,6 +116,10 @@ export function SelectPipettes(props: WizardTileProps): JSX.Element | null {
}
}, [pipetteType, pipetteGen, pipetteVolume, selectedPipetteName])

useEffect(() => {
handleScrollToBottom()
}, [pipetteType, pipetteVolume, pipetteGen])

const noPipette =
(pipettesByMount.left.pipetteName == null ||
pipettesByMount.left.tiprackDefURI == null) &&
Expand Down Expand Up @@ -187,6 +201,7 @@ export function SelectPipettes(props: WizardTileProps): JSX.Element | null {
flexDirection={DIRECTION_COLUMN}
overflowY={OVERFLOW_AUTO}
gridGap={SPACING.spacing32}
ref={ref}
>
<Flex
flexDirection={DIRECTION_COLUMN}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ vi.mock('../../../organisms')
vi.mock('../../../labware-defs/actions')
vi.mock('../utils')
const mockLocation = vi.fn()
window.HTMLElement.prototype.scrollIntoView = vi.fn()

vi.mock('react-router-dom', async importOriginal => {
const actual = await importOriginal<NavigateFunction>()
Expand Down

0 comments on commit ff1df36

Please sign in to comment.