Use same component for form title as Gutenberg does
Ordinary textarea doesn't support automatic height detection. [MAILPOET-2451]
This commit is contained in:
committed by
Jack Kitterhing
parent
7bf93b0c37
commit
b0a467d156
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
|
|||||||
import { useDispatch, useSelect } from '@wordpress/data';
|
import { useDispatch, useSelect } from '@wordpress/data';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
|
import Textarea from 'react-autosize-textarea';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [isSelected, setIsSelected] = useState(false);
|
const [isSelected, setIsSelected] = useState(false);
|
||||||
@@ -21,12 +22,12 @@ export default () => {
|
|||||||
<label htmlFor="post-title" className="screen-reader-text">
|
<label htmlFor="post-title" className="screen-reader-text">
|
||||||
{MailPoet.I18n.t('addFormName')}
|
{MailPoet.I18n.t('addFormName')}
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<Textarea
|
||||||
id="form-title"
|
id="form-title"
|
||||||
className="editor-post-title__input"
|
className="editor-post-title__input"
|
||||||
placeholder={MailPoet.I18n.t('addFormName')}
|
placeholder={MailPoet.I18n.t('addFormName')}
|
||||||
data-automation-id="form_title_input"
|
data-automation-id="form_title_input"
|
||||||
rows="1"
|
rows={1}
|
||||||
onFocus={() => setIsSelected(true)}
|
onFocus={() => setIsSelected(true)}
|
||||||
onKeyPress={() => setIsSelected(false)}
|
onKeyPress={() => setIsSelected(false)}
|
||||||
onBlur={() => setIsSelected(false)}
|
onBlur={() => setIsSelected(false)}
|
||||||
|
32
package-lock.json
generated
32
package-lock.json
generated
@@ -2236,6 +2236,18 @@
|
|||||||
"rememo": "^3.0.0",
|
"rememo": "^3.0.0",
|
||||||
"tinycolor2": "^1.4.1",
|
"tinycolor2": "^1.4.1",
|
||||||
"traverse": "^0.6.6"
|
"traverse": "^0.6.6"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react-autosize-textarea": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-iOSZK7RUuJ+iEwkJ9rqYciqtjQgrG1CCRFL6h8Bk61kODnRyEq4tS74IgXpI1t4S6jBBZVm+6ugaU+tWTlVxXg==",
|
||||||
|
"requires": {
|
||||||
|
"autosize": "^4.0.0",
|
||||||
|
"line-height": "^0.3.1",
|
||||||
|
"prop-types": "^15.5.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@wordpress/block-library": {
|
"@wordpress/block-library": {
|
||||||
@@ -2506,6 +2518,18 @@
|
|||||||
"redux-optimist": "^1.0.0",
|
"redux-optimist": "^1.0.0",
|
||||||
"refx": "^3.0.0",
|
"refx": "^3.0.0",
|
||||||
"rememo": "^3.0.0"
|
"rememo": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"react-autosize-textarea": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-iOSZK7RUuJ+iEwkJ9rqYciqtjQgrG1CCRFL6h8Bk61kODnRyEq4tS74IgXpI1t4S6jBBZVm+6ugaU+tWTlVxXg==",
|
||||||
|
"requires": {
|
||||||
|
"autosize": "^4.0.0",
|
||||||
|
"line-height": "^0.3.1",
|
||||||
|
"prop-types": "^15.5.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@wordpress/element": {
|
"@wordpress/element": {
|
||||||
@@ -10553,11 +10577,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-autosize-textarea": {
|
"react-autosize-textarea": {
|
||||||
"version": "3.0.3",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-autosize-textarea/-/react-autosize-textarea-7.0.0.tgz",
|
||||||
"integrity": "sha512-iOSZK7RUuJ+iEwkJ9rqYciqtjQgrG1CCRFL6h8Bk61kODnRyEq4tS74IgXpI1t4S6jBBZVm+6ugaU+tWTlVxXg==",
|
"integrity": "sha512-rGQLpGUaELvzy3NKzp0kkcppaUtZTptsyR0PGuLotaJDjwRbT0DpD000yCzETpXseJQ/eMsyVGDDHXjXP93u8w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"autosize": "^4.0.0",
|
"autosize": "^4.0.2",
|
||||||
"line-height": "^0.3.1",
|
"line-height": "^0.3.1",
|
||||||
"prop-types": "^15.5.6"
|
"prop-types": "^15.5.6"
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
"parsleyjs": "^2.8.1",
|
"parsleyjs": "^2.8.1",
|
||||||
"prop-types": "^15.6.2",
|
"prop-types": "^15.6.2",
|
||||||
"react": "^16.10.2",
|
"react": "^16.10.2",
|
||||||
|
"react-autosize-textarea": "^7.0.0",
|
||||||
"react-dom": "^16.10.2",
|
"react-dom": "^16.10.2",
|
||||||
"react-html-parser": "^2.0.2",
|
"react-html-parser": "^2.0.2",
|
||||||
"react-router-dom": "~5.1.2",
|
"react-router-dom": "~5.1.2",
|
||||||
|
Reference in New Issue
Block a user