Use same component for form title as Gutenberg does

Ordinary textarea doesn't support automatic height detection.
[MAILPOET-2451]
This commit is contained in:
Rostislav Wolny
2019-12-02 09:44:39 +01:00
committed by Jack Kitterhing
parent 7bf93b0c37
commit b0a467d156
3 changed files with 32 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { useDispatch, useSelect } from '@wordpress/data';
import classnames from 'classnames';
import MailPoet from 'mailpoet';
import Textarea from 'react-autosize-textarea';
export default () => {
const [isSelected, setIsSelected] = useState(false);
@@ -21,12 +22,12 @@ export default () => {
<label htmlFor="post-title" className="screen-reader-text">
{MailPoet.I18n.t('addFormName')}
</label>
<textarea
<Textarea
id="form-title"
className="editor-post-title__input"
placeholder={MailPoet.I18n.t('addFormName')}
data-automation-id="form_title_input"
rows="1"
rows={1}
onFocus={() => setIsSelected(true)}
onKeyPress={() => setIsSelected(false)}
onBlur={() => setIsSelected(false)}