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

fix(protocol-designer): liquid preservation in zoomed in slot and x button #16722

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Nov 7, 2024

closes AUTH-1016, partially addresses RQA-3526

Overview

Oof this was a bit confusing but i think the liquid edit experience is fixed now when you edit a labware with liquids in it already.

Test Plan and Hands on Testing

First check that the X button is added to deck setup tools and works as expected

Then, zoom into a slot with liquids and click done without doing anything, the liquids should be preserved until you press done
Next, zoom into a slot with liquids and click on different labware, liquids should not be preserved across labware but SHOULD be preserved if you go back to the original labware. once you press done, the liquids are not preserved.

Check that this pattern works for labware on the deck, labware on an adapter, labware on a module, and labware on an adapter on a module

here is a test protocol:
1.0 testing.json

Changelog

  • add x button to DeckSetupTools
  • keep track of the starting selected item state so done only updates if there are changes
  • refine logic for showing liquids on the labware in selectedHoweverLabware and split up component
  • fix tests

Risk assessment

low

@jerader jerader requested a review from a team as a code owner November 7, 2024 18:30
Comment on lines 100 to 105
const selectedSlotInfoRef = useRef<ZoomedIntoSlotInfoState>(selectedSlotInfo)
// initialize the selectedSlotInfoRef
useEffect(() => {
selectedSlotInfoRef.current = selectedSlotInfo
}, [selectedSlotInfo])

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason selectedSlotInfoRef wasn't correctly showing the initial state that selectedSlotInfo was showing so i had to add a useEffect to initialize it. I did some debugging and tried memoizing but that didn't work. Open to other ideas anyone has!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe creating a function or

use const selectedSlotInfo = useSelector(selectors.getZoomedInSlotInfo) in DeckSetupContainer and pass selectedSlotInfo as a prop?

function useUpdatedRef<T>(value: T): MutableRefObject<T> {
    const ref = useRef(value)
    if (!isEqual(ref.current, value)) {
      ref.current = value
    }
    return ref
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg that is a great idea, thank you!!!

@koji
Copy link
Contributor

koji commented Nov 8, 2024

could not add a module and a labware to a slot and could not change a labware

test.mov

@jerader
Copy link
Collaborator Author

jerader commented Nov 8, 2024

could not add a module and a labware to a slot and could not change a labware

test.mov

@koji oh wow, thanks for catching this! let me see if i can fix it before EOD

Comment on lines 106 to 108
// Check if initialSelectedSlotInfo is null and if selectedSlotInfo is
// fully populated since component rerenders
// TODO: need to optimize this better, find out why component rerenders
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to fix the bug. I think we need to refactor DeckSetupContainer, DeckSetupTools and DeckSetupDetails and how it gets and keeps track of the initial slot information. If you log anything in DeckSetupTools, you'll see it get re-rendered a bunch of times. Part of the re-rendering is due to the animation of zooming in. I guess what we have now is fine but definitely should be revisited and refactored post-release.

@jerader jerader changed the title fix(protocol-designer): liquid preservation in deck setup and x button fix(protocol-designer): liquid preservation in zoomed in slot and x button Nov 8, 2024
Copy link
Contributor

@koji koji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jerader jerader merged commit 7c4514f into edge Nov 8, 2024
12 checks passed
@jerader jerader deleted the pd_fix-liquids-deck-setup branch November 8, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants