diff --git a/.eslintrc b/.eslintrc index b3caa59e110484e128762039cca9c1c5c0645099..be0050216f5198f54da4da5beabf49284873554e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,8 @@ "sort-keys": ["error", "asc", { "caseSensitive": false, "natural": false - }] + }], + "jsx-a11y/click-events-have-key-events": "off", + "jsx-a11y/no-static-element-interactions": "off" } } diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js index a34c28588ab0114c6825b556ff82d155ec7e2fd8..f5e5995e99da3ae0151c64a98b41a669d139c0d4 100644 --- a/src/AnnotationCreation.js +++ b/src/AnnotationCreation.js @@ -244,7 +244,7 @@ class AnnotationCreation extends Component { updateGeometry={this.updateGeometry} windowId={windowId} /> - <form onSubmit={this.submitForm}> + <form onSubmit={this.submitForm} className={classes.section}> <Grid container> <Grid item xs={12}> <Typography variant="overline"> @@ -431,6 +431,12 @@ const styles = (theme) => ({ display: 'flex', flexWrap: 'wrap', }, + section: { + paddingBottom: theme.spacing(1), + paddingLeft: theme.spacing(2), + paddingRight: theme.spacing(1), + paddingTop: theme.spacing(2), + }, }); AnnotationCreation.propTypes = { diff --git a/src/TextEditor.js b/src/TextEditor.js index 536ba33b5bfb1236f44d200ec84e4190a3a8bd74..3dcaee93331711730837351c78e6bc8794bd7f62 100644 --- a/src/TextEditor.js +++ b/src/TextEditor.js @@ -20,6 +20,16 @@ class TextEditor extends Component { this.onChange = this.onChange.bind(this); this.handleKeyCommand = this.handleKeyCommand.bind(this); this.handleFormating = this.handleFormating.bind(this); + this.handleFocus = this.handleFocus.bind(this); + this.editorRef = React.createRef(); + } + + /** + * This is a kinda silly hack (but apparently recommended approach) to + * making sure the whole visible editor area is clickable, not just the first line. + */ + handleFocus() { + if (this.editorRef.current) this.editorRef.current.focus(); } /** */ @@ -58,6 +68,7 @@ class TextEditor extends Component { const { classes } = this.props; const { editorState } = this.state; const currentStyle = editorState.getCurrentInlineStyle(); + return ( <div> <ToggleButtonGroup @@ -77,11 +88,13 @@ class TextEditor extends Component { <ItalicIcon /> </ToggleButton> </ToggleButtonGroup> - <div className={classes.editorRoot}> + + <div className={classes.editorRoot} onClick={this.handleFocus}> <Editor editorState={editorState} handleKeyCommand={this.handleKeyCommand} onChange={this.onChange} + ref={this.editorRef} /> </div> </div>