[WebProfilerBundle] Increase compatibility of toolbar with Turbo #61167
+1
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you use Turbo 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:
symfony/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig
Lines 416 to 420 in 74895de
During a Turbo Drive navigation, the global
Sfjs
object will stay (which is fine) - and so will itsthis.sfwdt
variable of course. Thusthis.sfwdt
will always contain the reference to the toolbar of the first (non-Drive) request and thereforethis.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, sincegetElementById()
should be fast enough.