mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 00:09:47 +01:00
Make checkboxes changeable with key press
This commit is contained in:
@@ -44045,6 +44045,7 @@ exports[`Storyshots Forms|Checkbox Default 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -44068,6 +44069,7 @@ exports[`Storyshots Forms|Checkbox Default 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -44091,6 +44093,7 @@ exports[`Storyshots Forms|Checkbox Default 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -44121,6 +44124,7 @@ exports[`Storyshots Forms|Checkbox Disabled 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -44152,6 +44156,7 @@ exports[`Storyshots Forms|Checkbox With HelpText 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -44183,6 +44188,7 @@ exports[`Storyshots Forms|Checkbox With HelpText 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
@@ -47567,6 +47573,7 @@ exports[`Storyshots Modal|Modal With long tooltips 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="control"
|
className="control"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="checkbox"
|
className="checkbox"
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ export default class Checkbox extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onKeyDown = (event: React.KeyboardEvent) => {
|
||||||
|
const SPACE = 32;
|
||||||
|
if (event.keyCode === SPACE) {
|
||||||
|
this.onCheckboxChange();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderHelp = () => {
|
renderHelp = () => {
|
||||||
const { title, helpText } = this.props;
|
const { title, helpText } = this.props;
|
||||||
if (helpText && !title) {
|
if (helpText && !title) {
|
||||||
@@ -64,7 +71,7 @@ export default class Checkbox extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<div className="field">
|
<div className="field">
|
||||||
{this.renderLabelWithHelp()}
|
{this.renderLabelWithHelp()}
|
||||||
<div className="control" onClick={this.onCheckboxChange}>
|
<div className="control" onClick={this.onCheckboxChange} onKeyDown={this.onKeyDown}>
|
||||||
{/*
|
{/*
|
||||||
we have to ignore the next line,
|
we have to ignore the next line,
|
||||||
because jsx label does not the custom disabled attribute
|
because jsx label does not the custom disabled attribute
|
||||||
|
|||||||
Reference in New Issue
Block a user