[BUGFIX] Check if field exists when deleting items from `group` field
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Private / TypeScript / FormEngine / Element / AbstractSortableSelectItems.ts
index b8a4098..8e46d48 100644 (file)
@@ -85,8 +85,10 @@ export abstract class AbstractSortableSelectItems {
   private static removeOption(fieldElement: HTMLSelectElement, availableFieldElement: HTMLSelectElement): void {
     Array.from(fieldElement.querySelectorAll(':checked')).forEach((option: HTMLOptionElement): void => {
       const originalOption = <HTMLOptionElement>availableFieldElement.querySelector('option[value="' + option.value + '"]');
-      originalOption.classList.remove('hidden');
-      originalOption.disabled = false;
+      if (originalOption !== null) {
+        originalOption.classList.remove('hidden');
+        originalOption.disabled = false;
+      }
 
       fieldElement.removeChild(option);
     });