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

Properties dialog: Save changes when pressing Enter #24

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add Google Chrome support.
- Add option to open Treetop in a new tab.
- Focus search input when pressing '/'.
- Properties dialog: Save changes when pressing Enter.

### Changed

Expand Down
12 changes: 12 additions & 0 deletions src/treetop/PropertiesDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

let nameLabel: TextField;

/**
* Save the changes when the user presses Enter.
*/
function onKeyDown(e: CustomEvent | KeyboardEvent) {
e = e as KeyboardEvent;
if (e.key === 'Enter') {
save();
}
}

function handleOpened() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
nameLabel.focus();
Expand Down Expand Up @@ -99,6 +109,7 @@
bind:this={nameLabel}
bind:value={editTitle}
on:focus={handleTextFieldFocus}
on:keydown={onKeyDown}
label="Name"
style="width: 100%;" />
</div>
Expand All @@ -107,6 +118,7 @@
<TextField
bind:value={editUrl}
on:focus={handleTextFieldFocus}
on:keydown={onKeyDown}
label="Location"
style="width: 100%;" />
</div>
Expand Down