Skip to content

Commit

Permalink
UX: adds shortcuts for quote (q) and fast edit (e) (#14552)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Oct 7, 2021
1 parent a55642a commit 2af6052
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/assets/javascripts/discourse/app/components/quote-button.js
Expand Up @@ -232,6 +232,8 @@ export default Component.extend(KeyEnterEscape, {
}

$quoteButton.offset({ top, left });

this.element.querySelector("button")?.focus();
});
},

Expand Down Expand Up @@ -279,6 +281,24 @@ export default Component.extend(KeyEnterEscape, {
});
},

keyDown(event) {
this._super(...arguments);

if (!this.visible) {
return;
}

if (!this._displayFastEditInput && event.key === "e") {
this._toggleFastEditForm();
return false;
}

if (event.key === "q") {
this.insertQuote();
return false;
}
},

willDestroyElement() {
$(document)
.off("mousedown.quote-button")
Expand Down
Expand Up @@ -4,7 +4,9 @@
class="btn-flat insert-quote"
action=(action "insertQuote")
icon="quote-left"
label="post.quote_reply"}}
label="post.quote_reply"
title="post.quote_reply_shortcut"
}}
{{/if}}

{{#if siteSettings.enable_fast_edit}}
Expand All @@ -14,6 +16,7 @@
action=(action "_toggleFastEditForm")
label="post.quote_edit"
class="btn-flat quote-edit-label"
title="post.quote_edit_shortcut"
}}
{{/if}}
{{/if}}
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/common/base/topic-post.scss
Expand Up @@ -423,6 +423,12 @@ aside.quote {
color: var(--secondary-or-primary);
}

.btn:focus:not(:hover),
.btn:focus:not(:hover) .d-icon {
color: var(--secondary);
background-color: var(--secondary-high);
}

.insert-quote + .quote-sharing {
border-left: 1px solid rgba(255, 255, 255, 0.3);
}
Expand Down
2 changes: 2 additions & 0 deletions config/locales/client.en.yml
Expand Up @@ -3016,7 +3016,9 @@ en:

post:
quote_reply: "Quote"
quote_reply_shortcut: "Or press q"
quote_edit: "Edit"
quote_edit_shortcut: "Or press e"
quote_share: "Share"
edit_reason: "Reason: "
post_number: "post %{number}"
Expand Down

0 comments on commit 2af6052

Please sign in to comment.