Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/index.turbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ import Datepicker from './components/datepicker';
import { initFlowbite } from './components/index';
import Events from './dom/events';

// Patch Modal to add Turbo-compatible attributes to backdrop
// This prevents Turbo Morph from removing dynamically created backdrop elements
const originalCreateBackdrop = Modal.prototype._createBackdrop;
Modal.prototype._createBackdrop = function () {
originalCreateBackdrop.call(this);
if (this._backdropEl) {
this._backdropEl.setAttribute('data-turbo-permanent', '');
this._backdropEl.setAttribute('data-turbo-temporary', '');
}
};

// Since turbo maintainers refuse to add this event, we'll add it ourselves
// https://discuss.hotwired.dev/t/event-to-know-a-turbo-stream-has-been-rendered/1554/10
const afterRenderEvent = new Event('turbo:after-stream-render');
Expand Down