Button autoFocus

This commit is contained in:
futpib 2018-11-13 06:22:31 +03:00
parent 74badced08
commit 6b72eaa762
3 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,11 @@
const r = require('r-dom');
const Button = props => r.button({
ref: input => {
if (input && props.autoFocus) {
input.focus();
}
},
className: 'button',
...props,
}, props.children);

View File

@ -35,6 +35,7 @@ const Preferences = withStateHandlers(
r.div([
r(Button, {
style: { width: '100%' },
autoFocus: true,
onClick: toggle,
}, 'Close'),
]),
@ -68,6 +69,7 @@ const Preferences = withStateHandlers(
]),
] : [
r(Button, {
autoFocus: true,
onClick: toggle,
}, 'Cards'),
]));

View File

@ -34,6 +34,7 @@ const Preferences = withStateHandlers(
r.div([
r(Button, {
style: { width: '100%' },
autoFocus: true,
onClick: toggle,
}, 'Close'),
]),
@ -130,6 +131,7 @@ const Preferences = withStateHandlers(
]),
] : [
r(Button, {
autoFocus: true,
onClick: toggle,
}, 'Preferences'),
]));