Fix focus stealing
This commit is contained in:
parent
44ba44fc99
commit
c3deec41d7
|
@ -1,12 +1,18 @@
|
||||||
|
|
||||||
|
const {
|
||||||
|
memoizeWith,
|
||||||
|
} = require('ramda');
|
||||||
|
|
||||||
const r = require('r-dom');
|
const r = require('r-dom');
|
||||||
|
|
||||||
|
const ref = memoizeWith(autoFocus => String(Boolean(autoFocus)), autoFocus => input => {
|
||||||
|
if (input && autoFocus) {
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const Button = props => r.button({
|
const Button = props => r.button({
|
||||||
ref: input => {
|
ref,
|
||||||
if (input && props.autoFocus) {
|
|
||||||
input.focus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
className: 'button',
|
className: 'button',
|
||||||
...props,
|
...props,
|
||||||
}, props.children);
|
}, props.children);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user