Fix focus stealing

This commit is contained in:
futpib 2018-11-14 05:37:09 +03:00
parent 44ba44fc99
commit c3deec41d7

View File

@ -1,12 +1,18 @@
const {
memoizeWith,
} = require('ramda');
const r = require('r-dom'); const r = require('r-dom');
const Button = props => r.button({ const ref = memoizeWith(autoFocus => String(Boolean(autoFocus)), autoFocus => input => {
ref: input => { if (input && autoFocus) {
if (input && props.autoFocus) {
input.focus(); input.focus();
} }
}, });
const Button = props => r.button({
ref,
className: 'button', className: 'button',
...props, ...props,
}, props.children); }, props.children);