mui / base-ui

Base UI is an open-source library of accessible, unstyled UI components for React.
https://mui.com/base-ui/
MIT License
230 stars 42 forks source link

[TextareaAutosize] Resizing unstable #168

Closed hyorimitsu closed 4 months ago

hyorimitsu commented 6 months ago

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/modest-ellis-gzqt92

Steps:

  1. Attempt to resize the textarea in the provided sandbox link. You'll notice the resizing behavior is erratic and the style {{ backgroundColor: "yellow" }} fails to apply.
  2. Upon downgrading @mui/material to version 5.15.10, both the resizing behavior and style application work as expected.

Current behavior

https://github.com/mui/material-ui/assets/52403055/b4be59e3-dd5c-44bd-ac7e-3c2edb800040

Expected behavior

https://github.com/mui/material-ui/assets/52403055/c103b87f-572f-45d1-adfc-fc7f7b8bba6c

Context

No response

Your environment

npx @mui/envinfo ``` System: OS: Linux 5.10 Alpine Linux Binaries: Node: 20.11.0 - /usr/local/bin/node npm: 10.2.4 - /usr/local/bin/npm pnpm: Not Found Browsers: Chrome: Not Found npmPackages: @emotion/react: ^11.11.3 => 11.11.3 @emotion/styled: ^11.11.0 => 11.11.0 @mui/base: 5.0.0-beta.37 @mui/core-downloads-tracker: 5.15.11 @mui/icons-material: ^5.15.11 => 5.15.11 @mui/material: ^5.15.11 => 5.15.11 @mui/private-theming: 5.15.11 @mui/styled-engine: 5.15.11 @mui/system: 5.15.11 @mui/types: 7.2.13 @mui/utils: 5.15.11 @mui/x-charts: ^6.19.5 => 6.19.5 @mui/x-data-grid: ^6.19.5 => 6.19.5 @mui/x-date-pickers: ^6.19.5 => 6.19.5 @mui/x-tree-view: ^6.17.0 => 6.17.0 @types/react: ^18.2.58 => 18.2.58 react: ^18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 typescript: ^5.3.3 => 5.3.3 ```

Search keywords: TextareaAutosize,resizing,styles,5.15.11

Search keywords:

nktnet1 commented 6 months ago

I am facing a relevant issue with the TextField component set to "multiline" (i.e. textarea) below:

import React from "react";
import { TextField } from "@mui/material";

export default function EmptyTextarea() {
  return (
    <div>
      <TextField
        label="MUI Text Area"
        multiline
        variant="outlined"
        inputProps={{ style: { resize: "vertical" } }}
      />
    </div>
  );
}

The resizeable icon, which should appear at the bottom right corner as a result of the inputProps, is gone.

v5.15.11 bug

When inspecting the element, CSS says

resize: none;

Here is the sandbox:

Changing package.json in the sandbox back to @mui/materal v5.15.10 fixes the issue (i.e. the drag icon is visible again at the bottom right corner).

v5.15.10 works

ZeeshanTamboli commented 6 months ago

This issue is a regression from mui/material-ui#40789. I've submitted a PR, mui/material-ui#41369, to address the problem of styles not being applied.

ZeeshanTamboli commented 6 months ago

Style issue is resolved.

nktnet1 commented 6 months ago

@ZeeshanTamboli thank you for fixing the style issue!

Do you have any idea what the other issue is? i.e. regarding the glitchy drag in hyorimitsu's original post.

Using your CodeSandbox from https://github.com/mui/material-ui/pull/41369

After: https://codesandbox.io/p/sandbox/compassionate-napier-7tnq6l

This is what I see:

https://github.com/mui/base-ui/assets/86177399/d76c4425-db80-4aa4-888e-43dabb54ce9f

This is what the behaviour used to be like (the video shows 5.11.11 accidentally, but the last working is 5.15.10. Things broke in 5.15.11): https://codesandbox.io/p/sandbox/mui-textarea-and-textfield-yx88dk?file=%2Fpackage.json%3A13%2C30

https://github.com/mui/base-ui/assets/86177399/139c0190-ba0e-418c-b731-26dd0910ddbe

ZeeshanTamboli commented 6 months ago

@nktnet1 I'm not sure what the problem might be, but I'll take a look.

hyorimitsu commented 6 months ago

@ZeeshanTamboli Thank you for fixing the style issue!

You might already be aware, but just for your reference, I'd like to share my understanding of the bug related to resizing:

I apologize if there has been any misunderstanding.

ZeeshanTamboli commented 6 months ago

Thanks to @hyorimitsu for helping to pinpoint the cause of the issue. I've submitted a PR to address it - mui/base-ui#189.

colmtuite commented 5 months ago

Auto-sizing can be handled natively these days with field-sizing. So we're going to deprecate this component soon.

Demo

oliviertassinari commented 4 months ago

Even if deprecated, it will likely take two years to remove it, the time it will take for browser support to propagate https://github.com/mui/material-ui/issues/43720.

So I'm reopening, there are no real alternatives in production today, and it's still a regression.

If browser support propagates more rapidly, then the considerations would only be about backward compatibility, to give people time to migratre away.

ZeeshanTamboli commented 4 months ago

For those who are using @mui/base or @mui/material, this got fixed in https://github.com/mui/material-ui/pull/41638.

hyorimitsu commented 4 months ago

Thank you for the fix! It is greatly appreciated!