Skip to content

Commit

Permalink
feat(forms): Migrate to react-textarea-autosize (#83357)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper authored Jan 14, 2025
1 parent 2269fdb commit a7d46f9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"qrcode.react": "^3.1.0",
"query-string": "7.0.1",
"react": "18.2.0",
"react-autosize-textarea": "7.1.0",
"react-textarea-autosize": "8.5.7",
"react-date-range": "^1.4.0",
"react-dom": "18.2.0",
"react-grid-layout": "^1.3.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TextareaAutosize from 'react-autosize-textarea';
import TextareaAutosize from 'react-textarea-autosize';
import styled from '@emotion/styled';

import type {ModalRenderProps} from 'sentry/actionCreators/modal';
Expand Down
12 changes: 8 additions & 4 deletions static/app/components/forms/controls/textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import {forwardRef} from 'react';
import TextareaAutosize from 'react-autosize-textarea';
import TextareaAutosize, {type TextareaAutosizeProps} from 'react-textarea-autosize';
import isPropValid from '@emotion/is-prop-valid';
import styled from '@emotion/styled';

import type {InputStylesProps} from 'sentry/components/input';
import {inputStyles} from 'sentry/components/input';

export interface TextAreaProps
extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'css' | 'onResize'>,
extends Omit<
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
'css' | 'onResize' | 'style'
>,
InputStylesProps {
/**
* Enable autosizing of the textarea.
Expand All @@ -21,14 +24,15 @@ export interface TextAreaProps
* Number of rows to default to.
*/
rows?: number;
style?: TextareaAutosizeProps['style'];
}

const TextAreaControl = forwardRef(function TextAreaControl(
{autosize, rows, maxRows, size: _size, ...p}: TextAreaProps,
ref: React.Ref<HTMLTextAreaElement>
) {
return autosize ? (
<TextareaAutosize {...p} async ref={ref} rows={rows ? rows : 2} maxRows={maxRows} />
<TextareaAutosize {...p} ref={ref} rows={rows ? rows : 2} maxRows={maxRows} />
) : (
<textarea ref={ref} {...p} />
);
Expand All @@ -43,7 +47,7 @@ const TextArea = styled(TextAreaControl, {
${inputStyles};
line-height: ${p => p.theme.text.lineHeightBody};
/** Allow react-autosize-textarea to freely control height based on props. */
/** Allow react-textarea-autosize to freely control height based on props. */
${p =>
p.autosize &&
`
Expand Down
5 changes: 0 additions & 5 deletions static/app/utils/search/__mocks__/searchBoxTextArea.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions static/app/utils/search/searchBoxTextArea.tsx

This file was deleted.

1 change: 0 additions & 1 deletion tests/js/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jest
.spyOn(performanceForSentry, 'VisuallyCompleteWithData')
.mockImplementation(props => props.children as ReactElement);
jest.mock('scroll-to-element', () => jest.fn());
jest.mock('sentry/utils/search/searchBoxTextArea');

DANGEROUS_SET_TEST_HISTORY({
goBack: jest.fn(),
Expand Down
56 changes: 28 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.16.3":
"@babel/runtime@^7.16.3", "@babel/runtime@^7.20.13":
version "7.26.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
Expand Down Expand Up @@ -4886,11 +4886,6 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

autosize@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/autosize/-/autosize-4.0.2.tgz#073cfd07c8bf45da4b9fd153437f5bafbba1e4c9"
integrity sha512-jnSyH2d+qdfPGpWlcuhGiHmqBJ6g3X+8T+iRwFrHPLVcdoGJE/x6Qicm6aDHfTsbgZKxyV8UU/YB2p4cjKDRRA==

available-typed-arrays@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz#a5cc375d6a03c2efc87a553f3e0b1522def14846"
Expand Down Expand Up @@ -5479,11 +5474,6 @@ compression@^1.7.4:
safe-buffer "5.1.2"
vary "~1.1.2"

computed-style@~0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/computed-style/-/computed-style-0.1.4.tgz#7f344fd8584b2e425bedca4a1afc0e300bb05d74"
integrity sha1-fzRP2FhLLkJb7cpKGvwOMAuwXXQ=

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down Expand Up @@ -8965,13 +8955,6 @@ lilconfig@^3.1.2:
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.2.tgz#e4a7c3cb549e3a606c8dcc32e5ae1005e62c05cb"
integrity sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==

line-height@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/line-height/-/line-height-0.3.1.tgz#4b1205edde182872a5efa3c8f620b3187a9c54c9"
integrity sha1-SxIF7d4YKHKl76PI9iCzGHqcVMk=
dependencies:
computed-style "~0.1.3"

[email protected]:
version "2.0.4"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-2.0.4.tgz#d00318855905d2660d8c0822e3f5a4715855fc42"
Expand Down Expand Up @@ -10321,7 +10304,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"

prop-types@15, [email protected], prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@15, [email protected], prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -10424,15 +10407,6 @@ [email protected]:
iconv-lite "0.4.24"
unpipe "1.0.0"

[email protected]:
version "7.1.0"
resolved "https://registry.yarnpkg.com/react-autosize-textarea/-/react-autosize-textarea-7.1.0.tgz#902c84fc395a689ca3a484dfb6bc2be9ba3694d1"
integrity sha512-BHpjCDkuOlllZn3nLazY2F8oYO1tS2jHnWhcjTWQdcKiiMU6gHLNt/fzmqMSyerR0eTdKtfSIqtSeTtghNwS+g==
dependencies:
autosize "^4.0.2"
line-height "^0.3.1"
prop-types "^15.5.6"

react-date-range@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/react-date-range/-/react-date-range-1.4.0.tgz#d2073b85bdb4185e4dde288ce29198dd90074045"
Expand Down Expand Up @@ -10580,6 +10554,15 @@ [email protected]:
dependencies:
prop-types "^15.5.10"

[email protected]:
version "8.5.7"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.5.7.tgz#b2bf1913383a05ffef7fbc89c2ea21ba8133b023"
integrity sha512-2MqJ3p0Jh69yt9ktFIaZmORHXw4c4bxSIhCeWiFwmJ9EYKgLmuNII3e9c9b2UO+ijl4StnpZdqpxNIhTdHvqtQ==
dependencies:
"@babel/runtime" "^7.20.13"
use-composed-ref "^1.3.0"
use-latest "^1.2.1"

react-transition-group@^4.3.0:
version "4.4.2"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.2.tgz#8b59a56f09ced7b55cbd53c36768b922890d5470"
Expand Down Expand Up @@ -12042,6 +12025,23 @@ url-parse@^1.5.3:
querystringify "^2.1.1"
requires-port "^1.0.0"

use-composed-ref@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/use-composed-ref/-/use-composed-ref-1.4.0.tgz#09e023bf798d005286ad85cd20674bdf5770653b"
integrity sha512-djviaxuOOh7wkj0paeO1Q/4wMZ8Zrnag5H6yBvzN7AKKe8beOaED9SF5/ByLqsku8NP4zQqsvM2u3ew/tJK8/w==

use-isomorphic-layout-effect@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.2.0.tgz#afb292eb284c39219e8cb8d3d62d71999361a21d"
integrity sha512-q6ayo8DWoPZT0VdG4u3D3uxcgONP3Mevx2i2b0434cwWBoL+aelL1DzkXI6w3PhTZzUeR2kaVlZn70iCiseP6w==

use-latest@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/use-latest/-/use-latest-1.3.0.tgz#549b9b0d4c1761862072f0899c6f096eb379137a"
integrity sha512-mhg3xdm9NaM8q+gLT8KryJPnRFOz1/5XPBhmDEVZK1webPzDjrPk7f/mbpeLqTgB9msytYWANxgALOCJKnLvcQ==
dependencies:
use-isomorphic-layout-effect "^1.1.1"

util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit a7d46f9

Please sign in to comment.