-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed problem when usage navigation by modals
- Loading branch information
Showing
5 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
public/build/assets/app-B-hWsIbj.js → public/build/assets/app-wv8uX38s.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Modal } from 'bootstrap'; | ||
|
||
document.addEventListener('turbo:load', () => { | ||
document.querySelectorAll('.modal').forEach((modal) => { | ||
/** | ||
* Autofocus on modal. | ||
*/ | ||
modal.addEventListener('shown.bs.modal', () => { | ||
if (modal.querySelector('[autofocus]') !== null) { | ||
modal.querySelector('[autofocus]').focus(); | ||
} | ||
}); | ||
|
||
modal.addEventListener('hidden.bs.modal', () => { | ||
setTimeout(() => { | ||
document.activeElement?.blur(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
document.addEventListener('turbo:before-cache', () => { | ||
// Check if the body has the 'modal-open' class | ||
if (document.body.classList.contains('modal-open')) { | ||
if (window.location.href.indexOf('begin') > -1) { | ||
return; | ||
} | ||
|
||
// Find the currently visible modal | ||
const element = document.querySelector('.modal.show'); | ||
|
||
// Get or create the modal instance | ||
const modal = Modal.getOrCreateInstance(element); | ||
|
||
// Remove the 'fade' class from the modal element | ||
element.classList.remove('fade'); | ||
|
||
// Disable animation for the modal backdrop | ||
modal._backdrop._config.isAnimated = false; | ||
|
||
// Hide the modal | ||
modal.hide(); | ||
|
||
// Dispose the modal instance https://getbootstrap.com/docs/5.3/getting-started/javascript/#dispose-method | ||
// IT hack! | ||
modal.dispose(); | ||
element.classList.add('fade'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters