-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
When using the loading-states extension with the preload extension, loading states are triggered by the preloaded requests, but the preloaded requests do not undo the loading states. This causes loading states to persist even after the request has completed.
This is caused by preloaded requests firing htmx:beforeRequest which triggers the loading state, but preloaded requests do not trigger htmx:beforeOnLoad which is used to undo the loading state in loading-states.
This is replicated by:
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>
<script src="https://unpkg.com/[email protected]/preload.js"></script>
<script src="https://unpkg.com/[email protected]/loading-states.js"></script>
<style>[data-loading] { display: none; }</style>
</head>
<body hx-ext="loading-states,preload">
<button hx-get="?" preload="mouseover"
style="display: block; background: blue; color: white; height: 250px; width: 250px;">
Mouse over to preload
</button>
<div data-loading>Loading...</div>
</body>
</html>As preloaded requests are not intentionally initiated by the user and not necessarily needed, I suggest that preloaded requests should not trigger loading states at all.
Metadata
Metadata
Assignees
Labels
No labels