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

APP-6324: Make ToggleButtons purely presentational #585

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

ethanlook
Copy link
Contributor

For teleop, ToggleButtons get used for page navigation. When the user flips from Edit -> Monitor, the workspace gets saved. If there is an error while saving, we do not want to navigate to Monitor. Because the ToggleButtons set internal state, it appears as if toggling was successful. This makes the ToggleButtons purely presentational so that they only update when the parent changes the selected prop.

This will certainly be a breaking change somewhere when we bring it into App. I will do this PRIME upgrade myself and be sure to check all instances.

Change log

  • Remove internal selected state from ToggleButtons
  • Update tests
  • Update storybook

TODO

  • @mrloureed where will we update the corresponding design.viam.com page?

Copy link
Member

@zaporter-work zaporter-work left a comment

Choose a reason for hiding this comment

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

This will certainly be a breaking change somewhere when we bring it into App. I will do this PRIME upgrade myself and be sure to check all instances.

SGTM. I wonder if tests will also need updates.

@@ -51,7 +51,6 @@ $: getButtonClasses = (option: string) => {
};

const handleClick = (value: string) => {
selected = value;
Copy link
Member

@zaporter-work zaporter-work Oct 4, 2024

Choose a reason for hiding this comment

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

I wonder if we could put selected in a store and then when we handle the input event,we could just set $selected back to the original value (which IIRC would still trigger an update to this component even though the value is the same).

It might flash, but I think the transition would be quick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also an option, but this behavior is weird and I think the component should be purely presentational instead of mixing stateful concerns.

@ethanlook
Copy link
Contributor Author

@mrloureed is OOO - I will sync up with him about design.viam.com when he's back in office and keep this moving!

@ethanlook ethanlook merged commit 247338a into main Oct 7, 2024
4 checks passed
@ethanlook ethanlook deleted the APP-6324/ethanlook/toggle-buttons branch October 7, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants