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: [M3-7170] - Create VPC Region and Label Validation #9750

Merged
merged 11 commits into from
Oct 5, 2023

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Oct 3, 2023

Description 📝

Ensures that VPC region, label, and description validation error messages do not persist for VPC create flow.

Preview 📷

Screen.Recording.2023-10-04.at.5.39.30.PM.mov

How to test 🧪

  1. How to setup test environment?
  • With VPC flags on - on the dev environment or on the prod environment (with MSW): navigate to the Create VPC page.
  1. How to verify changes?
  • Without inputting anything, click on the Create VPC button. You should see errors pop up for the Region and VPC Label fields (as well as the subnet label field, but that's not part of this PR)
  • Verify that when you select a region, the error disappears.
  • Verify that when you input a label, the error disappears.
  • ** To test description error messages, you'll need to input a description > 255 characters
  • Verify that after initial scrolling to errors, the page does not continue to scroll if there are still errors on the page

@coliu-akamai coliu-akamai self-assigned this Oct 3, 2023
@coliu-akamai coliu-akamai added the VPC Relating to VPC project label Oct 3, 2023
@coliu-akamai coliu-akamai marked this pull request as ready for review October 3, 2023 20:40
@coliu-akamai coliu-akamai requested a review from a team as a code owner October 3, 2023 20:40
@coliu-akamai coliu-akamai requested review from mjac0bs, carrillo-erik, dwiley-akamai and tyler-akamai and removed request for a team October 3, 2023 20:40
…scription on VPC Create flow do not incorrectly persist
@jdamore-linode
Copy link
Contributor

jdamore-linode commented Oct 4, 2023

Note: due to the scrollErrorIntoView functionality, the page will jump to wherever there are errors. This may be worth looking into as a separate issue if it's disruptive enough. Video below:

I am finding this to be more disruptive than I initially thought it would be. I take it there's no way for us to revalidate the fields without also triggering the scroll functionality?

There doesn't seem to be a lot of context for this ticket -- I notice that the behavior we're implementing here is not consistent with other create forms in Cloud (for example, if you trigger an error in the Linode Create flow, the inline error messages persist until clicking the "Create Linode" button again). Given the jumping behavior, and the fact that this is not a pattern used elsewhere in the app (to my knowledge), is there any chance we might want to revisit this from a design perspective to ensure that this is really the right approach?

Edit: Oh, just saw M3-6894 😅 Please disregard

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

scrollErrorIntoView() takes optional arguments, so you could do

scrollErrorIntoView(undefined, { behavior: 'smooth' });

on L190 of VPCCreate.tsx to avoid a jarring jump

coliu-akamai and others added 2 commits October 4, 2023 12:45
Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>
@coliu-akamai
Copy link
Contributor Author

Thanks for pointing that out, @dwiley-akamai! It looks a lot smoother now:

Screen.Recording.2023-10-04.at.1.48.56.PM.mov

Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

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

Is it expected behavior for the page to continue to scroll after the first initial scroll?

Screen.Recording.2023-10-04.at.4.11.34.PM.mov

@tyler-akamai
Copy link
Contributor

Is it expected behavior for the page to continue to scroll after the first initial scroll?

Screen.Recording.2023-10-04.at.4.11.34.PM.mov

I am experiencing the same issue.

@coliu-akamai
Copy link
Contributor Author

thanks @hana-linode and @tyler-akamai! Confirmed with Andrew that we should try to get rid of that second scroll, looking into it :D

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

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

Thanks @coliu-akamai! Confirming that scrolling no longer continues after resolving the first error

@@ -151,6 +151,10 @@ const VPCCreate = () => {
visualToAPISubnetMapping
);
setFieldValue('subnets', subnetsAndErrors);

if (errors || generalAPIError || generalSubnetErrorsFromAPI) {
scrollErrorIntoView();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the { behavior: 'smooth' } tag from commit 95f64ca since we're no longer scrolling to an error after the initial error (+ looking through the codebase, nothing else has this tag)

@@ -185,11 +189,13 @@ const VPCCreate = () => {
validationSchema: createVPCSchema,
});

React.useEffect(() => {
Copy link
Contributor Author

@coliu-akamai coliu-akamai Oct 4, 2023

Choose a reason for hiding this comment

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

Moved the scrolling logic into the try-catch block of onCreateVPC and got rid of the useEffect in order to prevent rescrolling after initial scroll. (Note that a lot of other flows have this logic in a useEffect, so there might be potential rescrolling behavior there too!)

Copy link
Contributor

Choose a reason for hiding this comment

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

I went ahead and reintroduced the useEffect with the conditional logic for all three types of errors. If I removed the values from the dependency array, I didnt experience any of the page scrolling behavior. Just an FYI. I found your final solution much cleaner and don't recommend any further changes.

@coliu-akamai coliu-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Oct 4, 2023
Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

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

Confirmed that errors no longer persist! 🚫

@tyler-akamai
Copy link
Contributor

tyler-akamai commented Oct 5, 2023

LGTM, great job!

  • Verified errors pop up for the Region and VPC Label fields (as well as the subnet label field)
  • Verified that when you select a region, the error disappears.
  • Verified that when you input a label, the error disappears.
  • Verified test description error messages
  • Verified that after initial scrolling to errors, the page does not continue to scroll if there are still errors on the page

@coliu-akamai coliu-akamai merged commit 0b58eb2 into linode:develop Oct 5, 2023
12 of 13 checks passed
@coliu-akamai coliu-akamai deleted the feat-m3-7120-offshoot branch October 6, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add'tl Approval Needed Waiting on another approval! VPC Relating to VPC project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants