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

Text Area: clear / suffix / prefix buttons scroll out of view #7673

Closed
paodb opened this issue Aug 19, 2024 · 4 comments · Fixed by #7895
Closed

Text Area: clear / suffix / prefix buttons scroll out of view #7673

paodb opened this issue Aug 19, 2024 · 4 comments · Fixed by #7895
Assignees
Labels
BFP Bug fix prioritised by a customer

Comments

@paodb
Copy link
Collaborator

paodb commented Aug 19, 2024

Description

If the Text Area has a fixed height and contains a clear button or other suffix/prefix, these buttons can be scrolled out of view when entering a multiline content.

Expected outcome

Clear button or other suffix/prefix should stay visible.

Minimal reproducible example

return html`
      <style>
        vaadin-text-area {
          width: 100%;
          height: 150px;
        }
      </style>

      <vaadin-text-area label="Description" clear-button-visible >
        <vaadin-icon slot="prefix" icon="vaadin:vaadin-h"></vaadin-icon>
      </vaadin-text-area>
    `;

Steps to reproduce

  1. Add the snipped above to a page
  2. Start entering text with several lines until vertical scroll appears
  3. See clear button and sufix icon getting no longer visible while keep entering lines

Environment

Vaadin version(s): 24.4.8

Browsers

No response

@yuriy-fix yuriy-fix added BFP Bug fix prioritised by a customer target/24.4 labels Aug 20, 2024
@yuriy-fix
Copy link
Contributor

This issue has been added to the backlog priority queue for further investigation.

@sissbruecker
Copy link
Contributor

@paodb We looked into possible solutions, but unfortunately fixing this will likely require a breaking change. So fixing this will take longer, at least until the next minor, or possibly the next major. There is a related issue for allowing users to resize the text area, which would also require a breaking change, so we might want to tackle those together at some point.

As an alternative I can provide two simple workarounds using CSS:

1 - Make the internal textarea scrollable

This changes the internal text area to be scrollable. Note that this moves the scroll bar to the left of the clear button or any suffix component.

vaadin-text-area textarea {
  max-height: 100%;
  overflow: auto;
}

Bildschirmfoto 2024-09-02 um 10 21 28

2 - Use position: sticky on prefix and suffix components

This prevents prefix and suffix components scrolling out of the viewport. Note that this also moves the clear button to the top, otherwise the clear button would still scroll until it reaches the top and then stop scrolling there.

vaadin-text-area [slot="prefix"],
vaadin-text-area [slot="suffix"],
vaadin-text-area::part(clear-button) {
  align-self: flex-start;
  position: sticky;
  top: 0;
}

Bildschirmfoto 2024-09-02 um 10 24 16

@sissbruecker sissbruecker removed their assignment Sep 2, 2024
@rolfsmeds
Copy link
Contributor

Hmm, are there any other drawbacks to workaround #2 above than that the clear button is always rendered at the top instead of in the vertical center? Because if not, I'm starting to feel like that might be not only a very innocuous breaking change but possibly actually preferable, especially if prefix/suffix elements are also used. If that's the only drawback, I would be in favor of just shipping that change as-is in the next minor.

@sissbruecker
Copy link
Contributor

sissbruecker commented Sep 30, 2024

Currently, you can change the alignment of prefix, suffix or clear button using align-self with them being part of a flex container. If someone has customized the alignment to be anywhere else than at the top, then the outcome would be this:

Bildschirmaufnahme.2024-09-30.um.10.03.52.mov

If we make this change, then you'd have to change alignment using top instead, for example, for a center alignment you'd have to use something like:

vaadin-text-area [slot="prefix"],
vaadin-text-area [slot="suffix"],
vaadin-text-area::part(clear-button) {
  top: 50%;
  transform: translateY(-50%);
}

Edit: That's only the case when the component is scrollable though, using align-self should still work as before when the component is not scrollable. Still might be unexpected that you'd have to use different properties for alignment depending on whether the component can have a scroll bar or not, and you could easily miss this during development if you never test with sufficiently large content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFP Bug fix prioritised by a customer
Projects
None yet
4 participants