我有以下几点:
class MyTextArea extends React.Component {
handleClick = () => {
this.focus();
}
focus = () => this.ref.focus;
handleRef = (component) => {
this.ref = component;
};
render() {
return (
<div className="magicHelper" onClick={this.handleClick}>
<textarea></textarea>
</div>
);
}
}
我的 CSS:
.magicHelper {
width: 100%;
height: 100%;
}
textarea {
line-height: 32px;
}
我需要这个,因为我需要 textarea 的占位符在页面中水平和垂直居中。鉴于 textareas 不能垂直居中文本,我需要保持 textarea 的高度短。因此,我需要这样做,当用户在 textarea 之外单击时,认为他们正在单击 textarea,textarea 会自动聚焦。
这会导致 ESLint 错误:
"Visible, non-interactive elements with click handlers must have at least one keyboard listener"
.
如何更新上述内容以通过 eslint?