Skip to content

Commit 578c2e3

Browse files
minor #61167 [WebProfilerBundle] Increase compatibility of toolbar with Turbo (fritzmg)
This PR was merged into the 6.4 branch. Discussion ---------- [WebProfilerBundle] Increase compatibility of toolbar with Turbo | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- if yes, also update src/**/CHANGELOG.md --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | - | License | MIT If you use [Turbo](https://turbo.hotwired.dev/) in your Symfony project together with the `symfony/web-profiler-bundle`, there is one little annoyance: after every Turbo Drive navigation, the profiler's toolbar will be always open and the toggle button will not actually open/close it. Only after a full refresh does the button work again. This is because of the following code: https://github.com/symfony/symfony/blob/74895de13e0df9f4991d82a9c9cd956aee1c326c/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig#L416-L420 During a Turbo Drive navigation, the global `Sfjs` object will stay (which is fine) - and so will its `this.sfwdt` variable of course. Thus `this.sfwdt` will always contain the reference to the toolbar of the first (non-Drive) request and therefore `this.getSfwdt(token)` will always return that - instead of the new toolbar. This PR simply removes the `this.sfwdt` variable. Any performance gains from storing the reference to the toolbar is negligible anyway, since `getElementById()` should be fast enough. Commits ------- 735a5a2 Increase compatibility of debug toolbar compatibility with Turbo
2 parents 5b4525a + 735a5a2 commit 578c2e3

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@
413413
renderAjaxRequests: renderAjaxRequests,
414414
415415
getSfwdt: function(token) {
416-
if (!this.sfwdt) {
417-
this.sfwdt = document.getElementById('sfwdt' + token);
418-
}
419-
420-
return this.sfwdt;
416+
return document.getElementById('sfwdt' + token);
421417
},
422418
423419
load: function(selector, url, onSuccess, onError, options) {

0 commit comments

Comments
 (0)