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(textarea): textarea with autogrow will size to its contents #24205

Merged
merged 22 commits into from
Jul 27, 2022

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Nov 11, 2021

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resize behavior currently is using the scroll height of the control, to resize the outer container. This results in flaky behavior where the textarea will not correctly grow to its contents.

Issue Number: #24793, #21242

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added the package: core @ionic/core package label Nov 11, 2021
@liamdebeasi liamdebeasi changed the base branch from next to main December 13, 2021 17:20
@liamdebeasi liamdebeasi requested a review from a team as a code owner December 13, 2021 17:20
@Lxstr
Copy link

Lxstr commented Jan 6, 2022

Hi @sean-perkins. I would really like to try this solution but I am having trouble using a forked @ionic/core in my stenciljs project. I did manage a while ago as I was having trouble with textarea https://github.com/ionic-team/ionic-framework/issues/21242 but for the life of me can't figure out how I did it. I have looked at the contributing guide but it's vague. And I've tried npm link but got confused.

So far I have

From here how would I use this build in a way that I could easily swap back and forth with the real ionic release?

Ideally have both installed in my project and just import the one I want to test in the appropriate component.

Thanks in advance

@Lxstr
Copy link

Lxstr commented Jan 15, 2022

I've tested the new textarea and the bugs I was previously experiencing seem to be solved!! Awesome!

However, I do notice issues with the padding. It seems like the ::after elements is creating so much padding that it seems like an entire extra line is added at the bottom of the textarea that is un-useable.

I think the expectation would be little to no padding that the user can then add if required on textareas?

Thanks again for the fix and looking forward to the merge!

Screen Shot 2022-01-10 at 5 20 55 pm

Screen Shot 2022-01-10 at 5 34 14 pm

@sean-perkins
Copy link
Contributor Author

This PR is on hold until we finish our Playwright integration (being able to test across different browsers). Will rebase/resolve merge conflicts at that time.

@anagstef
Copy link
Contributor

Hello everyone! This PR indeed fixes all the issues we have with textarea and autogrow. Thank you for resolving them!!!

Is this getting prioritised anytime soon? I see that some Playwright PRs are merged.

Would love to help if I can. Thank you again! :)

@sean-perkins
Copy link
Contributor Author

Since Playwright was merged in with our 6.1.0 work, this PR is ready to be worked on and updated for 6.2.0. I cannot commit to a timeline on 6.2, since we just released, but you can expect this feature to be included in those changes.

@sean-perkins sean-perkins changed the base branch from main to feature-6.2 July 7, 2022 17:41
@sean-perkins sean-perkins changed the title feat(textarea): revised approach to auto-grow fix(textarea): textarea with autogrow will size to its contents Jul 7, 2022
@liamdebeasi
Copy link
Contributor

liamdebeasi commented Jul 19, 2022

There is also some strange flickering on iOS 13:

ios13-render.mov

@sean-perkins
Copy link
Contributor Author

@liamdebeasi good find. Looks like iOS 13 has some rendering difficulties with grid-area with multiple elements in a single container.

To work around this, the reflected pseudo element will be the only element affecting the layout. The native textarea will be absolutely positioned and fill the container's height when the textarea is using auto grow.

This appears to resolve the iOS 13 rendering bug and maintains auto grow behavior.

@sean-perkins sean-perkins requested a review from liamdebeasi July 25, 2022 17:31
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

It looks like this may actually be a scroll assist issue with duplicating the input while we adjust the scroll position

autogrow-flicker.mp4

Setting the following "fixes" the issue:

window.Ionic = {
    config: {
      scrollAssist: false
    }
  }

@sean-perkins
Copy link
Contributor Author

Ok I have no clue how my previous "fix" was working, because when running again I ran into the same behavior you noted. It was caused by the scroll assist.

Added a workaround that increases the height of the cloned input (textarea) to the height of the container (100%) when used with auto grow.

Confirmed on iOS 13 simulator that this resolves the white box rendering.

@sean-perkins sean-perkins requested a review from liamdebeasi July 26, 2022 20:15
Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Good to go when the comments below are addressed. Great job!

core/src/components/textarea/textarea.scss Outdated Show resolved Hide resolved
@github-actions github-actions bot added the package: vue @ionic/vue package label Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants