Skip to content

Commit

Permalink
fix: Inconsistent use of accents in Safari react-component#16
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang ping committed Jun 16, 2022
1 parent 12dc37f commit 22401aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/ResizableTextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import classNames from 'classnames';
import ResizeObserver from 'rc-resize-observer';
import omit from 'rc-util/lib/omit';
import classNames from 'classnames';
import calculateNodeHeight from './calculateNodeHeight';
import type { TextAreaProps } from '.';
import * as React from 'react';
import shallowEqual from 'shallowequal';
import type { TextAreaProps } from '.';
import calculateNodeHeight from './calculateNodeHeight';

// eslint-disable-next-line @typescript-eslint/naming-convention
enum RESIZE_STATUS {
Expand Down Expand Up @@ -70,10 +70,10 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {

resizeOnNextFrame = () => {
cancelAnimationFrame(this.nextFrameActionId);
this.nextFrameActionId = requestAnimationFrame(this.resizeTextarea);
this.nextFrameActionId = requestAnimationFrame(() => this.resizeTextarea());
};

resizeTextarea = () => {
resizeTextarea = (silent?: boolean) => {
const { autoSize } = this.props;
if (!autoSize || !this.textArea) {
return;
Expand All @@ -85,6 +85,12 @@ class ResizableTextArea extends React.Component<TextAreaProps, TextAreaState> {
minRows,
maxRows,
);
if (silent) {
this.setState({
textareaStyles,
});
return;
}
this.setState(
{ textareaStyles, resizeStatus: RESIZE_STATUS.RESIZING },
() => {
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import ResizableTextArea from './ResizableTextArea';
import type { AutoSizeType } from './ResizableTextArea';
import ResizableTextArea from './ResizableTextArea';

export type HTMLTextareaProps =
React.TextareaHTMLAttributes<HTMLTextAreaElement>;
Expand Down Expand Up @@ -62,7 +62,7 @@ class TextArea extends React.Component<TextAreaProps, TextAreaState> {
handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const { onChange } = this.props;
this.setValue(e.target.value, () => {
this.resizableTextArea.resizeTextarea();
this.resizableTextArea.resizeTextarea(true);
});
if (onChange) {
onChange(e);
Expand Down

0 comments on commit 22401aa

Please sign in to comment.