fix: initialize standalone toolbar#9950
fix: initialize standalone toolbar#9950michalsn wants to merge 2 commits intocodeigniter4:developfrom
Conversation
| init: function () { | ||
| this.toolbarContainer = document.getElementById("toolbarContainer"); | ||
| // Standalone debugbar pages do not have #toolbarContainer, use body as fallback. | ||
| this.toolbarContainer = document.getElementById("toolbarContainer") || document.body; |
There was a problem hiding this comment.
ciDebugBar.init() assumes that #toolbarContainer exists for both JavaScript and CSS theme handling, but on standalone debugbar pages (?debugbar_time=...) this element is missing. Falling back to document.body avoids errors, however without assigning the expected ID the existing CSS no longer matches, so the theme toggle appears non-functional.
| this.toolbarContainer = document.getElementById("toolbarContainer") || document.body; | |
| this.toolbarContainer = document.getElementById("toolbarContainer"); | |
| if (!this.toolbarContainer) { | |
| this.toolbarContainer = document.body; | |
| if (!document.body.id) { | |
| document.body.id = "toolbarContainer"; | |
| } | |
| } |
There was a problem hiding this comment.
You're right about the theme toggler - I'll fix that. But I'll keep standalone bootstrapping in a separate file to preserve clear responsibility boundaries.
There was a problem hiding this comment.
Appreciate you taking the time to explain your reasoning.
datamweb
left a comment
There was a problem hiding this comment.
LGTM!
In general, many of the existing issues in the debugging tools seem to stem from insufficient test coverage as well, which might be worth addressing over time.
Description
This PR fixes a bug where the Debug Toolbar loaded from
?debugbar_time=...(viaDebugbar-Linkheaders for AJAX/non-HTML responses) appeared but was not interactive.The fix adds a dedicated standalone bootstrap script for this mode, while keeping
toolbar.jsfocused on core toolbar behavior. It also provides aloadDoc()fallback only when the main loader flow is absent, so the History section keeps working on standalone toolbar pages.Fixes #9949
Checklist: