Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix modal error when no form is present

dominik-zeglen6a13084c394f
diff --git a/saleor/static/dashboard/js/components/modal.js b/saleor/static/dashboard/js/components/modal.js
index 862e38e0a4..1c372b8057 100644
--- a/saleor/static/dashboard/js/components/modal.js
+++ b/saleor/static/dashboard/js/components/modal.js
@@ -1,4 +1,4 @@
-import {initSelects} from './utils';
+import { initSelects } from './utils';
import SVGInjector from 'svg-injector-2';
// List of input types that can be autofocused after opening modal
@@ -19,7 +19,10 @@ export default $(document).ready((e) => {
$modal.html(response);
initSelects();
$modal.modal('open');
- $modal.find(focusInputs.join(','))[0].focus();
+ const inputs = $modal.find(focusInputs.join(','));
+ if (inputs.length) {
+ $modal.find(focusInputs.join(','))[0].focus();
+ }
// Image checkbox selector
$('.image_select-item-overlay').on('click', function (e) {
let id = $(e.target).attr('id');