From 46c9907a9b71a0865026413e4b23fd742e80aee4 Mon Sep 17 00:00:00 2001 From: mister-ben Date: Tue, 16 Jan 2024 17:43:39 +0100 Subject: [PATCH] fix: Fixes form markup in text track settings (#8557) --- src/js/tracks/text-track-settings.js | 12 ++++++++++-- test/unit/tracks/text-track-settings.test.js | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/js/tracks/text-track-settings.js b/src/js/tracks/text-track-settings.js index 6c55df235f..3859dbbfe8 100644 --- a/src/js/tracks/text-track-settings.js +++ b/src/js/tracks/text-track-settings.js @@ -6,6 +6,7 @@ import Component from '../component'; import ModalDialog from '../modal-dialog'; import {createEl} from '../utils/dom'; import * as Obj from '../utils/obj'; +import * as Guid from '../utils/guid.js'; import log from '../utils/log'; const LOCAL_STORAGE_KEY = 'vjs-text-track-settings'; @@ -303,6 +304,12 @@ class TextTrackSettings extends ModalDialog { * @param {string} key * Configuration key to use during creation. * + * @param {string} [legendId] + * Id of associated . + * + * @param {string} [type=label] + * Type of labelling element, `label` or `legend` + * * @return {string} * An HTML string. * @@ -312,12 +319,13 @@ class TextTrackSettings extends ModalDialog { const config = selectConfigs[key]; const id = config.id.replace('%s', this.id_); const selectLabelledbyIds = [legendId, id].join(' ').trim(); + const guid = `vjs_select_${Guid.newGUID()}`; return [ - `<${type} id="${id}" class="${type === 'label' ? 'vjs-label' : ''}">`, + `<${type} id="${id}"${type === 'label' ? ` for="${guid}" class="vjs-label"` : ''}>`, this.localize(config.label), ``, - `` ]. concat(config.options.map(o => { const optionId = id + '-' + o[1].replace(/\W+/g, ''); diff --git a/test/unit/tracks/text-track-settings.test.js b/test/unit/tracks/text-track-settings.test.js index 374770b0ca..cdaf375ffa 100644 --- a/test/unit/tracks/text-track-settings.test.js +++ b/test/unit/tracks/text-track-settings.test.js @@ -383,3 +383,17 @@ QUnit.test('should update on languagechange', function(assert) { player.dispose(); }); + +QUnit.test('should associate