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 tag input styles #20020

Merged
merged 7 commits into from
Dec 6, 2022
Merged

🪟 🐛 Fix tag input styles #20020

merged 7 commits into from
Dec 6, 2022

Conversation

flash1293
Copy link
Contributor

What

Fixes #18692

Before:
Screen Shot 2022-10-31 at 10 06 37

After (regular, hovered, focused, error):
Screenshot 2022-12-02 at 15 30 15
Screenshot 2022-12-02 at 15 30 19
Screenshot 2022-12-02 at 15 30 23
Screenshot 2022-12-02 at 15 31 08

How

Upgrading react-select made it necessary to overwrite a bunch of additional styles because react-select became more opinionated. This was necessary before, so the existing custom styles could easily be extended.

I couldn't figure out a native way to trigger the error state (I most likely missed it, but even if not we might want to add it at a later point in time), making it required by adding

          .required("you need this!")

to

makes it easy to do so in a synthetic way.

Drive-by changes

  • Removed some any-s, seems like the react-select typings got better.
  • Set aria-invalid on the react-select if it's in error state.

🚨 User Impact 🚨

Fixes the visual bug, no changes in behavior.

@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Dec 2, 2022
@flash1293 flash1293 changed the title Fix tag input styles 🪟 🐛 Fix tag input styles Dec 2, 2022
@flash1293 flash1293 marked this pull request as ready for review December 2, 2022 16:51
@flash1293 flash1293 requested a review from a team as a code owner December 2, 2022 16:51
@lmossman
Copy link
Contributor

lmossman commented Dec 2, 2022

I couldn't figure out a native way to trigger the error state

For the Postgres source, it is not showing the Required error state when empty because it is an optional field, so the yup .required() is not being applied here:

if (schema && isRequired) {
schema = schema.required("form.empty.error");
}

We may have other connectors with string array fields that are required, which should be using this error state, but I don't know off-hand which ones

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Had a couple comments coming from testing locally. Otherwise the code changes look good

...provided,
borderRadius: `${styles.borderRadius}`,
}),
control: (provided, state) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing I noticed when testing locally was that when I hovered my cursor over the TagInput it stays as the default cursor, whereas when I hover over the other text input fields it changes to a text cursor. Could we also make this TagInput have a text cursor, so that it is consistent? (And I feel a text cursor also makes sense here because the user is still expected to type values into the field)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

@flash1293 one more small nit here: when hovering over the X close button of one of the tags, could we go back to the default cursor (or maybe pointer, since that seems to be what we use for buttons)? It currently uses the text cursor which looks a little odd.

We should also use the same pointer style for the whole-component clear X button on the right side

...provided,
borderRadius: `${styles.borderRadius}`,
}),
control: (provided, state) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing I noticed while testing locally: this TagInput requires users to type in a value and then hit Enter for that value to be actually added to the field as a tag. If the users just types a value and then clicks away, the value they typed is erased.

I feel like this is not a very clear UX that the user has to press Enter in order for their changes to actually be saved, and it would be better if unfocusing the input also added their text as a tag. I think that behavior actually might have existed before we upgraded the react-select version.

Could you explore adding that functionality here? Also fine if you'd rather address that in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, it can be very annoying to a user, especially as it works fine when navigating via keyboard. I didn't find a "supported" way, but I think I came up with an acceptable workaround.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tried it out and I think this looks good! One question:

This needs to be implemented outside of the onBlur prop of react-select because it's not default behavior.

What do you mean by "it's not default behavior"? Isn't the handleDelete method we are passing to the onBlur prop also not default behavior?

@flash1293
Copy link
Contributor Author

@lmossman could you check again?

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Had one more small comment about cursor styling but otherwise LGTM!

Tested out locally and looks to be working well

...provided,
borderRadius: `${styles.borderRadius}`,
}),
control: (provided, state) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@flash1293 one more small nit here: when hovering over the X close button of one of the tags, could we go back to the default cursor (or maybe pointer, since that seems to be what we use for buttons)? It currently uses the text cursor which looks a little odd.

We should also use the same pointer style for the whole-component clear X button on the right side

...provided,
borderRadius: `${styles.borderRadius}`,
}),
control: (provided, state) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tried it out and I think this looks good! One question:

This needs to be implemented outside of the onBlur prop of react-select because it's not default behavior.

What do you mean by "it's not default behavior"? Isn't the handleDelete method we are passing to the onBlur prop also not default behavior?

@flash1293
Copy link
Contributor Author

What do you mean by "it's not default behavior"? Isn't the handleDelete method we are passing to the onBlur prop also not default behavior?

I just mean that the onBlur prop of the component is not called when you are actually bluring, that's why I had to add it to the surrounding div and wait for the event to bubble up. Just a technical detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tag input in connector configuration no longer matches the styles of the rest of the inputs
3 participants