mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
dropdown-widget: Pass aria-label for icon buttons in options.
This commit updates code to pass aria-label for icon buttons in dropdown widget options so that they can be used in dropdown_list.hbs template instead of directly defining them in the template file. We currently show buttons in saved snippets dropdown only so defining the labels in template file worked correctly but it is good to pass them as variables so that it is simpler to add buttons for other dropdowns when required.
This commit is contained in:
@@ -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 = {
|
||||
|
@@ -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;
|
||||
|
@@ -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}}
|
||||
|
@@ -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",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
Reference in New Issue
Block a user