react-component / textarea Goto Github PK
View Code? Open in Web Editor NEWReact Textarea
License: MIT License
React Textarea
License: MIT License
This recent PR on @types/react
added onResize in DOMAttributes<T>
type: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/63076/files
The onResize type is ReactEventHandler<T> | undefined;
This conflict with current type TextAreaProps
which defines onResize as (size: { width: number; height: number; }) => void
(see https://github.com/react-component/textarea/blob/master/src/index.tsx#L15)
The full error is:
error TS2430: Interface 'TextAreaProps' incorrectly extends interface 'TextareaHTMLAttributes<HTMLTextAreaElement>'.
Types of property 'onResize' are incompatible.
Type '((size: { width: number; height: number; }) => void) | undefined' is not assignable to type 'ReactEventHandler<HTMLTextAreaElement> | undefined'.
Type '(size: { width: number; height: number; }) => void' is not assignable to type 'ReactEventHandler<HTMLTextAreaElement>'.
Types of parameters 'size' and 'event' are incompatible.
Type 'SyntheticEvent<HTMLTextAreaElement, Event>' is missing the following properties from type '{ width: number; height: number; }': width, height
6 export interface TextAreaProps extends HTMLTextareaProps {
The package,json for this repo calls for [email protected].
Line 49 in 3dff6d2
But it uses a hook that wasn't introduced until @5.15.0.
textarea/src/ResizableTextArea.tsx
Line 3 in 3dff6d2
So, I'm getting this error when building
✘ [ERROR] Could not resolve "rc-util/es/hooks/useLayoutEffect"
node_modules/rc-textarea/es/ResizableTextArea.js:10:28:
10 │ import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
Ant Design support CSP via nonce in "csp" attribute of ConfigProvider. Textarea component uses inline style so nonce is not used and browser reports:
calculateNodeHeight.js:69 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-XXX'". Either the 'unsafe-inline' keyword, a hash ('sha256-+BQ4uy1Q8X6iksX2devUeYbbkg8ukCMGJSKXKhgEg9o='), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present.
One possible solution would be use of <style> element with nonce instead of "style" attribute.
Can someone please explain what's the purpose of these lines?
textarea/src/ResizableTextArea.tsx
Lines 151 to 155 in afc7c9e
设置 autosize 属性,指定 minRows 和 maxRows。当内容超过 maxRows 就会出现滚动条。但是此时不断的输入内容,当内容发生换行,滚动条并没有自动定位到输入区域的最底部,导致正在输入的内容会被遮住一部分。
此时如果继续输入,滚动条可能才会定位到最底部。
也就是说,假设一行只能显示 10 个字符,输入到第 14 个字符的时候,会有 4 个字符被遮住,再输入第 15 个字符,才会滚动到底部,把遮住的部分显示出来。
如果单纯的设置 autosize 为布尔值,并不会出现这个问题。
在 textarea 底部输入的时候,总能让输入的光标出现时可视区域内,不要遮住正在输入的内容。
Sometimes I can't use accents when using Safari with autoSize
.
Expected behavior (Chrome):
Using Safari 15.4 on macOS 12.3:
https://codesandbox.io/s/focused-tu-hlr3h1?file=/App.jsx
When I change the value, the textarea flickers. It seemed like the height suddenly got bigger and then recovered.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.