From 066fae62a705c2d08856debd270dab5d9757a7ee Mon Sep 17 00:00:00 2001 From: Ben Parizek Date: Tue, 23 Jan 2024 16:57:55 -0500 Subject: [PATCH] Fixes bug where link type dropdown loses focus due to missing select attribute --- src/assets/field/resources/LinkField.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/assets/field/resources/LinkField.js b/src/assets/field/resources/LinkField.js index 1cfecf2..4caedfb 100755 --- a/src/assets/field/resources/LinkField.js +++ b/src/assets/field/resources/LinkField.js @@ -31,6 +31,8 @@ this.$typeSelect = this.$field.find('.linkfield--type select'); this.type = this.$typeSelect.val(); + this.markOptionAsSelected(this.$typeSelect, this.type); + this.$optionsHolder = this.$field.find('.linkfield--typeOptions'); this.$options = this.$optionsHolder.find('.linkfield--typeOption'); this.$settingsHolder = this.$field.find('.linkfield--settings,.linkfield--target'); @@ -69,6 +71,7 @@ onChangeType: function(e) { this.type = this.$typeSelect.val(); + this.markOptionAsSelected(this.$typeSelect, this.type); this.$settingsHolder.toggleClass('hidden', this.type === '' || this.type === 'empty'); this.$options.addClass('hidden'); this.$options.filter('.' + this.type).removeClass('hidden'); @@ -87,6 +90,16 @@ this.$field.addClass(resizeClass); this.resizeClass = resizeClass; } - } + }, + + markOptionAsSelected: function(typeSelect, type) { + // mark option as 'selected' + typeSelect.find('option').each(function() { + let $this = $(this); + if ($this.val() === type) { + $this.attr('selected', true); + } + }); + }, }); })(jQuery);