Skip to content

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

making filename focusable in create file dialog

Ilian Sapundshiev1e2b60b76326
diff --git a/app/components/VerticalNavigation.js b/app/components/VerticalNavigation.js
index 31c9e7e09..ccb8218b7 100644
--- a/app/components/VerticalNavigation.js
+++ b/app/components/VerticalNavigation.js
@@ -284,7 +284,7 @@ class VerticalNavigation extends React.Component<Props, State> {
onClose={this.props.toggleSettingsDialog}
/>
<CreateFileDialog
- key={this.state.CreateFileDialogKey}
+ key={uuidv1()}
resetState={this.resetState}
open={this.props.isCreateFileDialogOpened}
selectedDirectoryPath={
diff --git a/app/components/dialogs/CreateFileDialog.js b/app/components/dialogs/CreateFileDialog.js
index a6f9a6329..35f77ab09 100644
--- a/app/components/dialogs/CreateFileDialog.js
+++ b/app/components/dialogs/CreateFileDialog.js
@@ -84,10 +84,7 @@ type State = {
open?: boolean,
fileName?: string,
fileContent?: string,
- fileType?: string,
- // suggestionTags?: Array<Tag>,
- // newlyAddedTags?: Array
- // allTags?: Array
+ fileType?: string
};
class CreateFileDialog extends React.Component<Props, State> {
@@ -96,31 +93,12 @@ class CreateFileDialog extends React.Component<Props, State> {
errorTextPath: false,
openFolder: false,
disableConfirmButton: true,
- // dirPath: '',
fileName: 'new note ' + AppConfig.beginTagContainer + formatDateTime4Tag(new Date(), true) + AppConfig.endTagContainer,
fileContent: '',
fileType: 'txt',
- // suggestionTags: [],
- // newlyAddedTags: [],
- // allTags: []
};
- /* componentWillReceiveProps = (nextProps: any) => {
- if (nextProps.open === true) {
- this.setState({
- selectedDirectoryPath: nextProps.selectedDirectoryPath || '',
- allTags: nextProps.allTags,
- fileName: 'new note ' + AppConfig.beginTagContainer + formatDateTime4Tag(new Date(), true) + AppConfig.endTagContainer,
- fileContent: '',
- newlyAddedTags: [],
- disableConfirmButton: true
- }, () => {
- // this.fileName.select();
- this.handleValidation();
- // this.fileName.focus();
- });
- }
- }; */
+ fileName;
handleTypeChange = (event: Object) => {
const target = event.target;
@@ -173,18 +151,6 @@ class CreateFileDialog extends React.Component<Props, State> {
});
};
- /* onAddTag = (tag) => {
- const { newlyAddedTags } = this.state;
- newlyAddedTags.push(tag);
- this.setState({ newlyAddedTags });
- };
-
- onRemoveTag = (tag) => {
- const { newlyAddedTags } = this.state;
- const modifiedTags = newlyAddedTags.filter(addedTag => addedTag.title !== tag.title);
- this.setState({ newlyAddedTags: modifiedTags });
- }; */
-
onConfirm = () => {
if (!this.state.disableConfirmButton) {
const { fileName, fileContent, fileType } = this.state;
@@ -195,12 +161,6 @@ class CreateFileDialog extends React.Component<Props, State> {
}
};
- /* addedTags = (tags) => {
- this.setState({
- suggestionTags: tags,
- });
- }; */
-
handleKeyPress = (event: any) => {
if (event.key === 'Enter' || event.keyCode === 13) {
// event.preventDefault();
@@ -221,6 +181,7 @@ class CreateFileDialog extends React.Component<Props, State> {
<TextField
fullWidth={true}
error={this.state.errorTextName}
+ autoFocus
margin="dense"
name="fileName"
label={i18n.t('core:fileName')}