TagSpaces is an offline, open source, document manager with tagging support
added autofoucs to create and rename directory dialogs
Ilian Sapundshievba7355cab74b
diff --git a/app/components/dialogs/CreateDirectoryDialog.js b/app/components/dialogs/CreateDirectoryDialog.jsindex c92a28b48..bacbab3e5 100644--- a/app/components/dialogs/CreateDirectoryDialog.js+++ b/app/components/dialogs/CreateDirectoryDialog.js@@ -45,6 +45,7 @@ type State = {name?: string};+class CreateDirectoryDialog extends React.Component<Props, State> {state = {inputError: false,@@ -105,9 +106,10 @@ class CreateDirectoryDialog extends React.Component<Props, State> {error={this.state.inputError}><TextField- fullWidth={true}+ fullWidtherror={this.state.inputError}margin="dense"+ autoFocusname="name"label={i18n.t('core:createNewDirectoryTitleName')}onChange={this.handleInputChange}diff --git a/app/components/dialogs/RenameDirectoryDialog.js b/app/components/dialogs/RenameDirectoryDialog.jsindex b735de79a..34828c6f8 100644--- a/app/components/dialogs/RenameDirectoryDialog.js+++ b/app/components/dialogs/RenameDirectoryDialog.js@@ -52,13 +52,14 @@ class RenameDirectoryDialog extends React.Component<Props, State> {name: '',};- componentWillReceiveProps = (nextProps: any) => {- if (nextProps.open === true) {- this.setState({- name: extractDirectoryName(nextProps.selectedDirectoryPath),- });+ static getDerivedStateFromProps(props) {+ if (props.open) {+ return {+ name: extractDirectoryName(props.selectedDirectoryPath)+ };}- };+ return null;+ }handleInputChange = (event: Object) => {const target = event.target;@@ -148,6 +149,7 @@ class RenameDirectoryDialog extends React.Component<Props, State> {<GenericDialogopen={this.props.open}onClose={this.props.onClose}+ autoFocusonEnterKey={(event) => onEnterKeyHandler(event, this.onConfirm)}renderTitle={this.renderTitle}renderContent={this.renderContent}diff --git a/app/components/menus/DirectoryMenu.js b/app/components/menus/DirectoryMenu.jsindex b542d6654..2d233f7ba 100644--- a/app/components/menus/DirectoryMenu.js+++ b/app/components/menus/DirectoryMenu.js@@ -18,6 +18,7 @@*/import React from 'react';+import uuidv1 from 'uuid';import ListItemIcon from '@material-ui/core/ListItemIcon';import ListItemText from '@material-ui/core/ListItemText';import Menu from '@material-ui/core/Menu';@@ -199,11 +200,13 @@ class DirectoryMenu extends React.Component<Props, State> {return (<div style={{ overflowY: 'hidden !important' }}><RenameDirectoryDialog+ key={uuidv1()}open={this.state.isRenameDirectoryDialogOpened}onClose={this.handleCloseDialogs}selectedDirectoryPath={this.props.directoryPath}/><CreateDirectoryDialog+ key={uuidv1()}open={this.state.isCreateDirectoryDialogOpened}onClose={this.handleCloseDialogs}selectedDirectoryPath={this.props.directoryPath}