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 r = require('r-dom');
const Button = props => r.button({ const Button = props => r.button({
ref: input => {
if (input && props.autoFocus) {
input.focus();
}
},
className: 'button', className: 'button',
...props, ...props,
}, props.children); }, props.children);

View File

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

View File

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