diff --git a/myproject/orders/templates/orders/order_form.html b/myproject/orders/templates/orders/order_form.html index 6f599ac..6e142e0 100644 --- a/myproject/orders/templates/orders/order_form.html +++ b/myproject/orders/templates/orders/order_form.html @@ -1288,7 +1288,30 @@ document.getElementById('save-customer-btn').addEventListener('click', function( .then(data => { if (data.success) { // Закрываем модальное окно - const modal = bootstrap.Modal.getInstance(document.getElementById('createCustomerModal')); + const modalElement = document.getElementById('createCustomerModal'); + const modal = bootstrap.Modal.getInstance(modalElement); + + // Слушаем событие полного закрытия модального окна + const handleHidden = () => { + // Удаляем обработчик после первого запуска + modalElement.removeEventListener('hidden.bs.modal', handleHidden); + + // Дополнительная очистка (на случай если Bootstrap не почистил) + const backdrop = document.querySelector('.modal-backdrop'); + if (backdrop) { + backdrop.remove(); + } + document.body.classList.remove('modal-open'); + document.body.style.paddingRight = ''; + + // Возвращаем фокус на форму заказа (опционально) + const orderForm = document.getElementById('order-form'); + if (orderForm) { + orderForm.focus(); + } + }; + + modalElement.addEventListener('hidden.bs.modal', handleHidden); modal.hide(); // Выбираем созданного клиента в Select2