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

Cleanup and refactors part 3 #464

Merged
merged 15 commits into from
Oct 28, 2020
Merged

Cleanup and refactors part 3 #464

merged 15 commits into from
Oct 28, 2020

Conversation

daigof
Copy link
Contributor

@daigof daigof commented Oct 27, 2020

Left comments in code. This could be the final cleanup. Anything u want throw in here let me know

@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 27, 2020 18:00 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 27, 2020 18:37 Inactive
Co-authored-by: Michael Altamirano <michaeljaltamirano@gmail.com>
@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 27, 2020 18:40 Inactive
Copy link
Contributor

@michaeljaltamirano michaeljaltamirano left a comment

Choose a reason for hiding this comment

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

37 of 40 files look good to go. The Request changes is for DesktopDropdown

Our TypeScript types and prop-types have been inconsistent in this component (and sub-components), which is understandable. Our TypeScript types only allowed string, not number, and it appears that is because the DesktopDropdown component only works when values are provided as strings. You can test this out yourself with the Storybook locally by changing the values in the options array to numbers instead of strings.

The HTML elements we use do accept other types (value?: string | number | readonly string[] | undefined), which is why our MobileDropdown works, since it relies on those native elements. Our DesktopDropdown component, however, does not, and as such any number we pass is in casted to a string in our event handlers. Because of this, when we update the state in the component, we don't see the result we're expecting.

So the changes requested here would be to make the DesktopDropdown compatible with value: number types. Feel free to @ me if you have any questions about this, and re-tag me when it's ready for re-review!

@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 27, 2020 21:01 Inactive
@daigof
Copy link
Contributor Author

daigof commented Oct 27, 2020

@michaeljaltamirano thanks for the feedback, I didnt wanted to dig much into Dropdown, it was sort of a confusing and just wanted to cleanup without impact. But screw that I overhauled the component, I took the requirement to allow string | number | undefined for values (as initial value and optionType). And I reflected that in the story changes so we can test all scenarios.

I suppose there will be some Chromatic changes because of this

All changes are contained in this last Commit 2f9c0cd

@@ -93,22 +94,22 @@ export const DesktopDropdown = ({
isOpen={isOpen}
optionsContainerMaxHeight={optionsContainerMaxHeight}
role="menu"
aria-activedescendant={value}
aria-activedescendant={`${value}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is quite what we want--if value is undefined or null we will then pass in "undefined" or "null".

value ? `${value}` : undefined

perhaps? (It looks like the DOM type is string | undefined).

Copy link
Contributor

@michaeljaltamirano michaeljaltamirano left a comment

Choose a reason for hiding this comment

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

@michaeljaltamirano thanks for the feedback, I didnt wanted to dig much into Dropdown, it was sort of a confusing and just wanted to cleanup without impact. But screw that I overhauled the component, I took the requirement to allow string | number | undefined for values (as initial value and optionType). And I reflected that in the story changes so we can test all scenarios.

I suppose there will be some Chromatic changes because of this

All changes are contained in this last Commit 2f9c0cd

Yep, the chromatic tests are breaking, which I don't think should be happen for this kind of re-factor.

  1. It looks like we can avoid it for the Mobile story by using the same label: let's keep it pre-populating with First Option instead of Number Value. If you want to add an explicit number value option, let's not make it the first one to keep the visual tests passing.

Screen Shot 2020-10-27 at 5 08 57 PM

  1. It looks like the changes have also changed the default behavior of the DesktopDropdown, which now auto-populates:

Screen Shot 2020-10-27 at 5 08 48 PM

Before:

Screen Shot 2020-10-27 at 5 31 48 PM

After: undefined option has aria-checked="true" before interaction

Screen Shot 2020-10-27 at 5 32 05 PM

It does look like we're passing the actual type in the Desktop version now, which is nice, but let's button this up a bit before merging it in.

@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 28, 2020 13:11 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 28, 2020 13:13 Inactive
@daigof
Copy link
Contributor Author

daigof commented Oct 28, 2020

@michaeljaltamirano changes are in this commit 5179ca7

I just left strings and numbers as values examples and restored the original labels for the story.

@snags88 snags88 temporarily deployed to curology-radiance-pr-464 October 28, 2020 13:59 Inactive
@@ -30,9 +29,9 @@ type DropdownProps = {
optionsContainerMaxHeight?: string;
textAlign?: 'left' | 'center';
/**
* The currently selected option. Can mount as `null`
* The currently selected option. Can be initially `undefined`
Copy link
Contributor

Choose a reason for hiding this comment

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

Previous versions showed that anything undefined would be pre-selected, so I think that we might want to re-word this. I'm just not sure what initially undefined means, and what the use case would be of something going from initially undefined to some truthy value.

Copy link
Contributor

@michaeljaltamirano michaeljaltamirano left a comment

Choose a reason for hiding this comment

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

I appreciate the comments in onDesktopSelectChange. This LGTM. I left one other comment but it is non-blocking (though I do think it would be helpful to be clarified, lest there be confusion about it in the future re: undefined use cases.)

Since there were more refactors for Dropdowns than other components let's just be sure to especially double-check those when updating consumer apps.

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