From b11a861da2e3cf7ed3c72882888722d1281be37c Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Thu, 26 Jan 2023 11:03:33 +1000
Subject: [PATCH] =?UTF-8?q?Issue=20#3305706=20by=20znerol,=20SandeepSingh1?=
 =?UTF-8?q?99,=20ivnish,=20smustgrave,=20Spokje,=20=C3=B8kse,=20ranjith=5F?=
 =?UTF-8?q?kumar=5Fk=5Fu,=20coffeemakr,=20DavorHorvacki:=20Uncaught=20Type?=
 =?UTF-8?q?Error:=20this.$pluginSelect.find(...)[0]=20is=20undefined?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 core/modules/field_ui/field_ui.es6.js | 6 +++++-
 core/modules/field_ui/field_ui.js     | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/modules/field_ui/field_ui.es6.js b/core/modules/field_ui/field_ui.es6.js
index 950df384ca7c..10f5581e50c4 100644
--- a/core/modules/field_ui/field_ui.es6.js
+++ b/core/modules/field_ui/field_ui.es6.js
@@ -365,10 +365,14 @@
       // disabled previously. Pseudo-fields do not have default formatters,
       // we just return to 'visible' for those.
       if (this.region === 'hidden') {
+        const pluginSelect =
+          typeof this.$pluginSelect.find('option')[0] !== 'undefined'
+            ? this.$pluginSelect.find('option')[0].value
+            : undefined;
         const value =
           typeof this.defaultPlugin !== 'undefined'
             ? this.defaultPlugin
-            : this.$pluginSelect.find('option')[0].value;
+            : pluginSelect;
 
         if (typeof value !== 'undefined') {
           if (this.$pluginSelect.length) {
diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js
index 06aba8ee1310..400033244675 100644
--- a/core/modules/field_ui/field_ui.js
+++ b/core/modules/field_ui/field_ui.js
@@ -150,7 +150,8 @@
         this.$regionSelect[0].value = region;
       }
       if (this.region === 'hidden') {
-        var value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin : this.$pluginSelect.find('option')[0].value;
+        var pluginSelect = typeof this.$pluginSelect.find('option')[0] !== 'undefined' ? this.$pluginSelect.find('option')[0].value : undefined;
+        var value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin : pluginSelect;
         if (typeof value !== 'undefined') {
           if (this.$pluginSelect.length) {
             this.$pluginSelect[0].value = value;
-- 
GitLab