Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Optimizing autofocus in some dialogs

Ilian Sapundshievf83732e06c8f
diff --git a/app/components/dialogs/CreateTagGroupDialog.js b/app/components/dialogs/CreateTagGroupDialog.js
index 7ccc9d5b9..02bd44428 100644
--- a/app/components/dialogs/CreateTagGroupDialog.js
+++ b/app/components/dialogs/CreateTagGroupDialog.js
@@ -32,7 +32,7 @@ import i18n from '../../services/i18n';
import TransparentBackground from '../TransparentBackground';
type Props = {
- open?: boolean,
+ open: boolean,
onClose: () => void,
createTagGroup: (tagGroup: TagGroup) => void,
color: string,
@@ -40,16 +40,16 @@ type Props = {
};
type State = {
- inputError?: boolean,
- displayColorPicker?: boolean,
- displayTextColorPicker?: boolean,
- disableConfirmButton?: boolean,
- uuid?: string,
- title?: string,
- color?: string,
- textcolor?: string,
- children?: string,
- expanded?: boolean
+ inputError: boolean,
+ displayColorPicker: boolean,
+ displayTextColorPicker: boolean,
+ disableConfirmButton: boolean,
+ uuid: string,
+ title: string,
+ color: string,
+ textcolor: string,
+ children: string,
+ expanded: boolean
};
class CreateTagGroupDialog extends React.Component<Props, State> {
diff --git a/app/components/dialogs/CreateTagsDialog.js b/app/components/dialogs/CreateTagsDialog.js
index 756203f29..13d5a53dc 100644
--- a/app/components/dialogs/CreateTagsDialog.js
+++ b/app/components/dialogs/CreateTagsDialog.js
@@ -128,6 +128,7 @@ class CreateTagsDialog extends React.Component<Props, State> {
<GenericDialog
open={this.props.open}
onClose={this.props.onClose}
+ autoFocus
onEnterKey={(event) => onEnterKeyHandler(event, this.onConfirm)}
renderTitle={this.renderTitle}
renderContent={this.renderContent}
diff --git a/app/components/dialogs/EditEntryTagDialog.js b/app/components/dialogs/EditEntryTagDialog.js
index 1dcc00ea5..347327c03 100644
--- a/app/components/dialogs/EditEntryTagDialog.js
+++ b/app/components/dialogs/EditEntryTagDialog.js
@@ -37,7 +37,7 @@ import { getSelectedTag } from '../../reducers/app';
import TaggingActions, { defaultTagLocation } from '../../reducers/tagging-actions';
import { isDateTimeTag } from '../../utils/dates';
-const styles = theme => ({
+const styles = () => ({
root: {
width: 550,
height: '100%',
@@ -56,8 +56,8 @@ type Props = {
open: boolean
};
-const GeoTagEditor = Pro && Pro.UI ? Pro.UI.GeoTagEditor : false;
-const DateTagEditor = Pro && Pro.UI ? Pro.UI.DateTagEditor : false;
+const GeoTagEditor = Pro && Pro.UI ? Pro.UI.GeoTagEditor : React.Fragment;
+const DateTagEditor = Pro && Pro.UI ? Pro.UI.DateTagEditor : React.Fragment;
const EditEntryTagDialog = (props: Props) => {
const [disableConfirmButton, setDisableConfirmButton] = useState(true);
@@ -123,6 +123,7 @@ const EditEntryTagDialog = (props: Props) => {
error={errorTag}
margin="dense"
name="title"
+ autoFocus
label={i18n.t('core:editTag')}
onChange={event => {
const target = event.target;
@@ -133,7 +134,6 @@ const EditEntryTagDialog = (props: Props) => {
/>
{errorTag && <FormHelperText>{i18n.t('core:tagTitleHelper')}</FormHelperText>}
</FormControl>
- { !Pro && <h3>{i18n.t('core:needProVersion')}</h3> }
{ showGeoEditor && <GeoTagEditor key={title} geoTag={title} onChange={setTitle} zoom={title === defaultTagLocation ? 2 : undefined} /> }
{ showDatePeriodEditor && <DateTagEditor key={title} datePeriodTag={title} onChange={setTitle} /> }
</DialogContent>
diff --git a/app/components/dialogs/EditTagDialog.js b/app/components/dialogs/EditTagDialog.js
index 417b06e32..4b1dc82be 100644
--- a/app/components/dialogs/EditTagDialog.js
+++ b/app/components/dialogs/EditTagDialog.js
@@ -63,7 +63,7 @@ class EditTagDialog extends React.Component<Props, State> {
modifiedDate: ''
};
- componentWillReceiveProps = ({ open, selectedTag }) => {
+ componentWillReceiveProps = ({ open, selectedTag }: Props) => {
if (open === true) {
this.setState({
disableConfirmButton: !selectedTag.title,
@@ -165,8 +165,6 @@ class EditTagDialog extends React.Component<Props, State> {
},
};
-
- console.log('Mod ' + modifiedDate);
return (
<DialogContent style={{ overflow: 'visible' }}>
<FormControl
@@ -184,6 +182,7 @@ class EditTagDialog extends React.Component<Props, State> {
error={this.state.inputError}
margin="dense"
name="title"
+ autoFocus
label={i18n.t('core:editTag')}
onChange={this.handleInputChange}
value={this.state.title}
diff --git a/app/components/dialogs/EditTagGroupDialog.js b/app/components/dialogs/EditTagGroupDialog.js
index 37dc3ba3a..e8d76fa90 100644
--- a/app/components/dialogs/EditTagGroupDialog.js
+++ b/app/components/dialogs/EditTagGroupDialog.js
@@ -191,6 +191,7 @@ class EditTagGroupDialog extends React.Component<Props, State> {
error={this.state.inputError}
margin="dense"
name="title"
+ autoFocus
label={i18n.t('core:editTagGroupNewName')}
onChange={this.handleInputChange}
value={this.state.title}