Skip to content

Commit

Permalink
Properties dialog: Save changes when pressing Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
msmolens committed Dec 29, 2023
1 parent baecbc0 commit b5a05d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit b5a05d4

Please sign in to comment.