Fix admin messages never auto-dismissing (root cause) #66
Reference in New Issue
Block a user
Delete Branch "fix/admin-messages-auto-dismiss-v3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
PRs #54 and #64 attempted to fix persistent admin notifications but neither addressed the root cause. After thorough investigation:
w-messagesStimulus controller has noconnect()lifecycle method. ItsautoClearValueonly applies to messages added dynamically via JavaScript (theadd()method). Server-rendered<li>elements — produced by Django's messages framework after a redirect — sit in the DOM indefinitely with no auto-dismiss.data-w-messages-auto-clear-value="8000"correctly handles dynamic messages but has zero effect on server-rendered ones.{% ifchanged %}de-duplication was cosmetic and doesn't address persistence.Fix
<li>elements withdata-server-rendered<script>that queries those elements and removes them after 8 seconds (matching the dynamic message auto-clear timeout)has-messagesbody class when all messages are gone{% ifchanged %}de-duplicationTest plan