Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

dropdown-widget: Pass aria-label for icon buttons in options.

Sahil Batrae7cb472188d4
diff --git a/web/src/dropdown_widget.ts b/web/src/dropdown_widget.ts
index 63adf8899bc..b639f06ff5d 100644
--- a/web/src/dropdown_widget.ts
+++ b/web/src/dropdown_widget.ts
@@ -35,6 +35,8 @@ export type Option = {
bold_current_selection?: boolean;
has_delete_icon?: boolean;
has_edit_icon?: boolean;
+ delete_icon_label?: string;
+ edit_icon_label?: string;
};
export type DropdownWidgetOptions = {
diff --git a/web/src/saved_snippets.ts b/web/src/saved_snippets.ts
index 5bae6e59561..41fd99206f5 100644
--- a/web/src/saved_snippets.ts
+++ b/web/src/saved_snippets.ts
@@ -1,5 +1,6 @@
import * as blueslip from "./blueslip.ts";
import type {Option} from "./dropdown_widget.ts";
+import {$t} from "./i18n.ts";
import type {StateData} from "./state_data.ts";
import * as util from "./util.ts";
@@ -40,6 +41,8 @@ export function get_options_for_dropdown_widget(): Option[] {
bold_current_selection: true,
has_delete_icon: true,
has_edit_icon: true,
+ delete_icon_label: $t({defaultMessage: "Delete snippet"}),
+ edit_icon_label: $t({defaultMessage: "Edit snippet"}),
}));
return options;
diff --git a/web/templates/dropdown_list.hbs b/web/templates/dropdown_list.hbs
index 0b4de86ade5..e55b94c4e14 100644
--- a/web/templates/dropdown_list.hbs
+++ b/web/templates/dropdown_list.hbs
@@ -6,10 +6,10 @@
{{#if bold_current_selection}}
<span class="dropdown-list-bold-selected">{{name}}</span>
{{#if has_edit_icon}}
- {{> components/icon_button custom_classes="dropdown-list-edit" intent="neutral" icon="edit" aria-label=(t "Edit snippet") }}
+ {{> components/icon_button custom_classes="dropdown-list-edit" intent="neutral" icon="edit" aria-label=edit_icon_label }}
{{/if}}
{{#if has_delete_icon}}
- {{> components/icon_button custom_classes="dropdown-list-delete" intent="danger" icon="trash" aria-label=(t "Delete snippet") }}
+ {{> components/icon_button custom_classes="dropdown-list-delete" intent="danger" icon="trash" aria-label=delete_icon_label }}
{{/if}}
{{else}}
{{name}}
diff --git a/web/tests/saved_snippets.test.cjs b/web/tests/saved_snippets.test.cjs
index aef6f88ec22..1deadfafd6f 100644
--- a/web/tests/saved_snippets.test.cjs
+++ b/web/tests/saved_snippets.test.cjs
@@ -64,6 +64,8 @@ run_test("options for dropdown widget", () => {
bold_current_selection: true,
has_delete_icon: true,
has_edit_icon: true,
+ delete_icon_label: "translated: Delete snippet",
+ edit_icon_label: "translated: Edit snippet",
},
{
unique_id: 2,
@@ -72,6 +74,8 @@ run_test("options for dropdown widget", () => {
bold_current_selection: true,
has_delete_icon: true,
has_edit_icon: true,
+ delete_icon_label: "translated: Delete snippet",
+ edit_icon_label: "translated: Edit snippet",
},
{
unique_id: 1,
@@ -80,6 +84,8 @@ run_test("options for dropdown widget", () => {
bold_current_selection: true,
has_delete_icon: true,
has_edit_icon: true,
+ delete_icon_label: "translated: Delete snippet",
+ edit_icon_label: "translated: Edit snippet",
},
]);
});