-
Notifications
You must be signed in to change notification settings - Fork 201
fix(textarea): drag and grow behaviors #2506
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
Conversation
8afeb69
to
743bfd7
Compare
🚀 Deployed on https://pr-2506--spectrum-css.netlify.app |
File metricsSummaryTotal size: 3.97 MB*
Detailstextfield
* Results are not gzipped or minified. * An ASCII character in UTF-8 is 8 bits or 1 byte. |
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.
Thanks for working on this! It's looking good. One thing I'm seeing in Storybook with Grows turned on, if I turn Invalid on, then the icon gets misaligned. Is this expected to be fixed in #2380 and therefore not a concern for this PR?
93ed9f6
to
1705e06
Compare
components/textfield/index.css
Outdated
.spectrum-Textfield-input { | ||
.spectrum-Textfield-input { | ||
resize: both; | ||
block-size: unset; |
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'm glad you got this block-size
update in there. In addition to the XL height bug fix you mentioned in the PR description, it also lets the textarea height size appropriately if the rows attribute it used, e.g. rows="5"
.
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.
While I still think that using block-size: unset;
is a good idea, I've removed it from this PR as it causes a few issues downstream with SWC and with the quiet variants.
Text areas default to two rows in most browsers, resulting in fields like quiet that previously displayed as one line, displaying as two by default. It also would change the heights on some fields. This is significant enough of a change to be its own PR and can be revisited later, likely as part of the Spectrum 2 migration. It would likely require work on the SWC end.
The benefits of keeping the change would be the ability to use the rows
attribute on the textarea. SWC lists rows in their API for Text area but it does not seem to work currently. The design specs do not specify a fixed height, only a minimum height.
1705e06
to
cd5cb9e
Compare
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.
components/textfield/index.css
Outdated
@@ -553,26 +553,15 @@ governing permissions and limitations under the License. | |||
|
|||
/****** Validation Icon - Invalid ⚠️ ******/ | |||
.spectrum-Textfield.is-invalid & { | |||
justify-self: end; |
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.
This is attempt to address the invalid and valid icon position when drag behavior is enabled.
justify-self: end;
positioning the icon at the end of the grid and using padding instead of inset address the spacing around the icon.
However there is still an issue with the min-size for the text-area, where you can drag the text area to be smaller than the original text area and the icon appears outside of the text area. I think there may be some browser differences that would need looking into here as well.
Leaving off this change from this PR, as it will have quite a few effects downstream with SWC. Especially with textareas defaulting to a rows value of 2 in most browsers, the height would look much different by default without rows being defined. This was noticeable in the quiet variations. This still seems like a good change to make in the future, especially if web components wants to allow the rows attribute to be used. This will be discussed further and has been noted to reevaluate during the imminent S2 migration of text area.
Restore some CSS related to textarea invalid icon alignment. The behavior was different between the docs and Storybook. The issue was due to using flex-direction column, which stretches the text area to 100% width without changing its width. And the browser drag behavior sets an inline fixed width on the textarea, resulting in the misalignment.
Fixes issues where when using the drag to resize, the width could become smaller than the minimum width, resulting in misalignment of the invalid icon. Also adds mod custom property for resize.
Improved resize behavior on text area, and alignment of the validation icon in various scenarios. Adds to the stories for Text area to try and account for more combinations of the options available. An issue still exists with long text within the field label no longer wrapping and preventing the default defined width from being used.
9b95ebd
to
23a0f11
Compare
I got really close with addressing some of the alignment issues and improving the resize/drag behavior. There are still some issues with it that I'll explain. I also discovered some areas that need more Storybook coverage. Improvements and changes
Screen.Recording.2024-03-15.at.2.05.49.PM.movRemaining issuesIn the Storybook Chromatic testing view of Text area, I noticed that the wrapping example was no longer wrapping. This surfaced an alignment issue as well. On the parent, Screen.Recording.2024-03-15.at.2.22.45.PM.movI'm not sure if there is a way around this---I'm open to ideas! Increased Storybook coverage neededI will do this as a separate PR, but in testing this I discovered a few areas that could use increased Storybook coverage and controls, that would be useful to fully test this. The character counter and help text are demoed in the docs but not represented in Storybook. The character counter especially is important to test as it is displayed within the second column of the grid layout being used for alignment. |
Description
Updates text area to display grow and drag behaviors.
Design Guidance:
Changes:
How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
On the docs page for TextArea
In storybook:
Regression testing
Validate:
Screenshots
Before
After
To-do list