-
Notifications
You must be signed in to change notification settings - Fork 101
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(ui-text-input): fix long before elements overflowing in TextInput, Select,SimpleSelect #1809
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment above
<span css={styles?.layout}> | ||
{beforeElement && ( | ||
<span css={styles?.layout}> | ||
{beforeElement && <div css={styles?.beforePadding}></div>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont like this solution, that we have an extra DOM element just to add a bit of padding. (this is needed when there is renderBeforeInput
, e.g. Tag
s) But I could not find a better solution, what I've tried:
-
Use a tricky CSS, that adds padding if the first child of the
layout
span
is NOT theinputLayout
:'&:has(> :first-child:not([class$="textInput__inputLayout"]))'
. While this works nice in the browser it crashes in Vite tests because of a bug in a dependency: Some uses of:has
throw "not a valid selector" dperini/nwsapi#123
So using this solution means that users will need to use either the latest Jest or a patched version of Jest wherenwsapi
is at the latest version, which is not cool IMO. -
Do some JS magic to figure out the width of the
renderBeforeInput
elements: This is what the old code was doing, now it would need to be even more complicated because we're not wrappingrenderBeforeInput
in adiv
anymore, so we need to take care of the case that its a React fragment/text/whatever weirdness users put there.
While the current solution is a bit ugly because of the extra DOM element and the padding is added if the renderBeforeInput
's width is 0, its still the best I could find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed adding padding to the container would be an easier solution, please fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a padding to the container instead of the divider solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. later we could simplify this by removing the margins and paddings from the Tags and using flex gap but that would require rewriting our examples and breaking existing code that users need to update
a3ce97e
to
edcab73
Compare
… TextInput, Select, SimpleSelect Closes: INSTUI-4344 When adding lots of elements to renderBeforeInput for example Tags it was overflowing the input field. Also when there are more than one line of elements keep the input field in the same line if there is enough space TEST PLAN: Add lots of elements to renderBeforeInput to Select,SimpleSelect,TextInput. They should wrap, not overflow
edcab73
to
6f3723f
Compare
Closes: INSTUI-4344
When adding lots of elements like Tags it was overflowing the input field, this commit fixes it
This bug was introduced with #1696 when we added a Flex layout without wrap.
TEST PLAN:
Add lots of elements to renderBeforeInput to Select,SimpleSelect,TextInput. They should wrap not overflow