From 60b7fcabdadad1738e13b5777f5c440f46bb4681 Mon Sep 17 00:00:00 2001 From: lianbenjamin <79077248+lianbenjamin@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:37:27 +0300 Subject: [PATCH] feat(FEC-13835): sort captions menu in alphabetic order (#879) ### Description of the Changes **enhancement.** - sort the languages in the captions menu in an alphabetic order - keep `Off` language at the end of the list #### Resolves FEC-13835 --- src/components/captions-menu/captions-menu.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/captions-menu/captions-menu.tsx b/src/components/captions-menu/captions-menu.tsx index c7ab1ce5a..d1cb65abe 100644 --- a/src/components/captions-menu/captions-menu.tsx +++ b/src/components/captions-menu/captions-menu.tsx @@ -112,11 +112,13 @@ class CaptionsMenu extends Component { * @memberof CaptionsMenu */ render(props: any): VNode { - const textOptions = props.textTracks.map(t => ({ - label: t.label || t.language, - active: t.active, - value: t - })); + const textOptions = props.textTracks + .map(t => ({ + label: t.label || t.language, + active: t.active, + value: t + })) + .sort((a, b) => a.label > b.label || a.label === 'Off' ? 1 : -1); if (props.showAdvancedCaptionsMenu) { textOptions.push({label: props.advancedCaptionsSettingsText, value: props.advancedCaptionsSettingsText, active: false});