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 issues with vendor selector behavior #4521

Merged
merged 9 commits into from
Dec 19, 2023

Conversation

jpople
Copy link
Contributor

@jpople jpople commented Dec 15, 2023

Closes #PROD-1450

Description Of Changes

  • After selecting a vendor, the vendor's name can now be edited as a text field
  • On clicking or tabbing out of the vendor selector, typed input is not lost
  • X button to clear input now only renders if the input is non-empty
  • Changed error message when trying to enter a system name that's already taken to match designs

Loom demo

AC of "This input is used in all places where a vendor can be selected from compass" has its own ticket PROD-1355 and is not part of this PR.

Code Changes

  • Vendor selector input now stealthily switches between being a select which controls name/vendor ID simultaneously and a text input which controls only the name
  • Removed no-longer-required "Separate vendor selector" feature flag
  • Updated Yup validation schema for new error message

Steps to Confirm

With Compass enabled on the manual "Add system" form:

  • Enter a Compass vendor name and accept suggestions
  • System name should be freely editable
  • Clear input by clicking the X
  • Suggestions should disappear and input should return to typeahead state

From a clean form:

  • Enter a new system name (not the name of a Compass vendor), then click outside the input
  • Input value should be retained

From a clean form:

  • Enter a new system name, then press Tab
  • Input value should be retained, "Description" field below should be focused

From a clean form:

  • Enter a duplicate system name
  • Error message should read: "You already have a system called $WHAT_YOU_ENTERED. Please specify a unique name for the system".

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Copy link

vercel bot commented Dec 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2023 8:46pm

Copy link

cypress bot commented Dec 15, 2023

Passing run #5724 ↗︎

0 4 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Merge faf8eeb into 7e2b55e...
Project: fides Commit: 35d0e940fa ℹ️
Status: Passed Duration: 00:35 💡
Started: Dec 19, 2023 8:55 PM Ended: Dec 19, 2023 8:56 PM

Review all test suite changes for PR #4521 ↗︎

Copy link
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

still need to UAT, but leaving some comments first!

clients/admin-ui/cypress/e2e/systems-plus.cy.ts Outdated Show resolved Hide resolved
clients/admin-ui/cypress/e2e/systems-plus.cy.ts Outdated Show resolved Hide resolved
</FormControl>
);

const textInput = (
Copy link
Contributor

Choose a reason for hiding this comment

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

it's a little weird for this to be a constant as opposed to a separate React component with props passed in. not a huge deal, but I think

{isTypeahead ? <TypeaheadSelect isInvalid={isInvalid} ... /> : <TextInput isInvalid={isInvalid} ... />}

is a little clearer that we are expecting components. if it feels like we are repeating too many of the same props, can also do

const props = { isInvalid: false }
{isTypeahead ? <TypeaheadSelect {...props} /> : <TextInput {...props} />}

Copy link
Contributor

Choose a reason for hiding this comment

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

can this component use the CustomInput shared one from inputs.tsx? or is it too customized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only real difference with the CustomInput is that this one is wrapped in an InputGroup with the clear indicator as an InputRightComponent-- do you think it's reasonable to add handling for that case into the generic input?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it could be! maybe if the default input is wrapped in an InputGroup (I don't think that actually renders anything but I might be wrong about that), then it could take an optional InputRightElement? it's always a balance though—we don't want to add anything too bespoke to the common components, but I think having a right element could be useful for other inputs too so if it doesn't make the code too much more complicated, I think it's worth a shot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allisonking After messing with putting the typeahead into its own component I'm sort of inclined to think that it's not worth it-- both components need access to things from the shared state and from useFormikContext and useField, so I'd either have to duplicate those hook calls or pass in a whole bunch (like, on the order of 10) of one-off helper methods to the typeahead as props, which I think makes it harder to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, thanks for looking into it!

clients/admin-ui/src/features/system/VendorSelector.tsx Outdated Show resolved Hide resolved
@allisonking
Copy link
Contributor

this is looking great @jpople ! only thing I thought was kind of weird in my testing was that the "Create new system "{word}" option goes away once you start typing more letters? I guess maybe because we've switched to the other input type? I'd expect it to keep saying "Create a new system "{word}" as I keep typing

Screen.Recording.2023-12-18.at.3.42.53.PM.mov

I don't think it's a big deal, but that's the only thing I saw, everything else seems to meet the AC! 🎉

{ ...touched, vendor_id: true, name: true },
// do not validate if a new option was created; this prevents
// incorrectly showing a "required field" error while a value is in
// the field
Copy link
Contributor Author

@jpople jpople Dec 19, 2023

Choose a reason for hiding this comment

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

The only scenario I can think of where not validating here (and the similar call below this) would cause problems would be when manually creating a system with a taken name, but validation for name uniqueness seems to work even when shouldValidate is false here? I tried also to use Formik's manual validateField methods for this which seemed more elegant, but I couldn't make them work so this seemed fine instead.

aria-hidden
position="absolute"
backgroundColor="transparent"
style={{ marginTop: "31.52px", marginLeft: "13px" }}
Copy link
Contributor Author

@jpople jpople Dec 19, 2023

Choose a reason for hiding this comment

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

For some reason these margins don't get applied when using the Chakra style props, so I had to do it this way instead.

Copy link
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

🎉

@jpople jpople merged commit d03ce76 into main Dec 19, 2023
13 checks passed
@jpople jpople deleted the jpople/prod-1450/vendor-selector-fixes branch December 19, 2023 20:58
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.

2 participants