Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus on text inputs when profile management modals are opened #1200

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/pages/Profiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="card-content">
<p>This profile will store its own mods independently from other profiles.</p>
<br/>
<input class="input" v-model="newProfileName" />
<input class="input" v-model="newProfileName" ref="profileNameInput" />
<br/><br/>
<span class="tag is-dark" v-if="newProfileName === '' || makeProfileNameSafe(newProfileName) === ''">
Profile name required
Expand Down Expand Up @@ -86,7 +86,7 @@
<button class="button is-info"
@click="importProfile(); showImportModal = false;">From file</button>
<button class="button is-primary"
@click="profileImportCode = ''; showImportModal = false; showCodeModal = true;">From code</button>
@click="showImportModal = false; openProfileCodeModal();">From code</button>
</div>
</div>
</div>
Expand All @@ -101,7 +101,7 @@
<p class="card-header-title">Enter the profile code</p>
</header>
<div class="card-content">
<input type="text" class="input" v-model="profileImportCode" />
<input type="text" class="input" v-model="profileImportCode" ref="profileCodeInput" />
<br />
<br />
<span class="tag is-dark" v-if="profileImportCode === ''">You haven't entered a code</span>
Expand Down Expand Up @@ -243,6 +243,7 @@
<script lang='ts'>
import Vue from 'vue';
import Component from 'vue-class-component';
import { Ref } from 'vue-property-decorator';
import { Hero, Progress } from '../components/all';
import sanitize from 'sanitize-filename';
import ZipProvider from '../providers/generic/zip/ZipProvider';
Expand Down Expand Up @@ -284,6 +285,9 @@ let fs: FsProvider;
}
})
export default class Profiles extends Vue {
@Ref() readonly profileCodeInput: HTMLInputElement | undefined;
@Ref() readonly profileNameInput: HTMLInputElement | undefined;

private profileList: string[] = ['Default'];

private selectedProfile: string = '';
Expand Down Expand Up @@ -338,6 +342,11 @@ export default class Profiles extends Vue {
this.newProfileName = this.selectedProfile;
this.addingProfileType = "Rename";
this.renamingProfile = true;
this.$nextTick(() => {
if (this.profileNameInput) {
this.profileNameInput.focus();
}
});
}

async performRename(newName: string) {
Expand All @@ -359,6 +368,11 @@ export default class Profiles extends Vue {
this.newProfileName = nameOverride || '';
this.addingProfile = true;
this.addingProfileType = type;
this.$nextTick(() => {
if (this.profileNameInput) {
this.profileNameInput.focus();
}
});
}

createProfile(profile: string) {
Expand Down Expand Up @@ -478,6 +492,16 @@ export default class Profiles extends Vue {
});
}

openProfileCodeModal() {
this.profileImportCode = '';
this.showCodeModal = true;
this.$nextTick(() => {
if (this.profileCodeInput) {
this.profileCodeInput.focus();
}
});
}

async importProfileUsingCode() {
try {
const filepath = await ProfileImportExport.downloadProfileCode(this.profileImportCode);
Expand Down
Loading