Skip to content

Fix dump panel hidden when closing a dump #24665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2017

Conversation

julienfalque
Copy link
Contributor

@julienfalque julienfalque commented Oct 22, 2017

Q A
Branch? 2.8
Bug fix? yes-ish
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

In the dump panel of the debug bar, when closing a dump the panel sometimes get hidden:

before

This is because when the size of the panel is reduced, if the mouse is not over it anymore, the :hover pseudo-class does not apply anymore.

I "fixed" it by setting a min-height on the panel when closing a dump. The min-height is removed when leaving the panel on purpose:

after

For now I only tested it on Firefox 56 on Arch Linux.

@nicolas-grekas
Copy link
Member

I didn't try the behavior on a page where the dump is displayed inline. Does this change anything in this situation? (eg in the dump() panel, or when using {{ dump() }})

@julienfalque
Copy link
Contributor Author

Didn't try either but it's worth checking before merging. I'll have a look.

@julienfalque julienfalque force-pushed the fix-dump-panel-toggling branch 2 times, most recently from b1d290f to b16ffd2 Compare October 23, 2017 21:23
@julienfalque
Copy link
Contributor Author

I updated the PR: previous version was not working with inline dumps (the panel variable was set to null with the first inline dump as the debug bar wasn't loaded yet, and then never updated).

I also noticed that all dumps have a z-index: 99999. What's the reason for that?

@ogizanagi
Copy link
Contributor

@julienfalque : I still get a Uncaught TypeError: Cannot read property 'style' of undefined at toggle error in the profiler with your latest fix :/

@julienfalque julienfalque force-pushed the fix-dump-panel-toggling branch from b16ffd2 to ece2e1f Compare October 24, 2017 05:48
@julienfalque
Copy link
Contributor Author

Woops. Should be fixed now.

@@ -138,6 +138,11 @@ function toggle(a, recursive) {
} else if (/\bsf-dump-expanded\b/.test(oldClass)) {
arrow = '▶';
newClass = 'sf-dump-compact';

if ('undefined' !== typeof window.Sfdump.debugBarPanel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means var-dumper knows something about the Symfony panel.
Can't we decouple things and alter the logic in the panel's twig file instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I used a custom event to decouple toggle detection and panel min-height handling.

@julienfalque julienfalque force-pushed the fix-dump-panel-toggling branch 2 times, most recently from 55a7515 to 4b58a83 Compare October 24, 2017 22:56
@@ -141,6 +141,11 @@ function toggle(a, recursive) {
} else {
return false;
}

s.dispatchEvent(new CustomEvent('sfbeforedumptoggle', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaks on IE11?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't care about IE for Symfony development tools (we do care about Microsoft Edge though).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do care about IE11 for things running in the toolbar, because this one is injected in the page itself, and so anything breaking the JS could break the page itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that today, IE11 supports the WDT properly (we just had an issue with the SVG rendering in the past doing wonky stuff when the size was not defined in the SVG, and we fixed it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. Symfony debug toolbars are related to the backend. If you have a Symfony-related problem in your app, you should be able to use any browser. So there's no need to support legacy browsers. The only exception are Ajax requests ... but that's two different things: you can use IE to debug frontend + JS errors related to Ajax and any other browser to debug the Symfony responses to those Ajax requests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least failing gracefully should be required IMHO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz but if the frontend is broken because of the JS injected by the toolbar, you cannot debug the frontend because the toolbar causes extra errors.
It is OK if some feature does not work. It is not OK for the JS to break.

@nicolas-grekas
Copy link
Member

Status: needs work

(should degrade gracefully on non-supported OSes)

@julienfalque
Copy link
Contributor Author

Rewritten using document.createEvent(). Support by older browsers should be better. Though I cannot confirm it right now. Can someone have a look?

@@ -141,6 +141,15 @@ function toggle(a, recursive) {
} else {
return false;
}

var event = doc.createEvent('Event');
event.initEvent(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this call should be on one line.
to further enhance compat, what about wrapping the new logic in a check like: if (doc.createEvent) {...}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@julienfalque julienfalque force-pushed the fix-dump-panel-toggling branch from 70ba05a to 2b9b6e0 Compare November 5, 2017 15:37
event.initEvent('sf-dump-expanded' === newClass ? 'sfbeforedumpexpand' : 'sfbeforedumpcollapse', true, false);
}

s.dispatchEvent(event);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be inside the "if"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, indeed... Also added to the if condition.

@fabpot
Copy link
Member

fabpot commented Nov 5, 2017

Thank you @julienfalque.

@fabpot fabpot merged commit 2e0b263 into symfony:2.8 Nov 5, 2017
fabpot added a commit that referenced this pull request Nov 5, 2017
This PR was merged into the 2.8 branch.

Discussion
----------

Fix dump panel hidden when closing a dump

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes-ish
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

In the dump panel of the debug bar, when closing a dump the panel sometimes get hidden:

![before](https://user-images.githubusercontent.com/1736542/31867025-615e9c48-b788-11e7-8329-96716c211523.gif)

This is because when the size of the panel is reduced, if the mouse is not over it anymore, the `:hover` pseudo-class does not apply anymore.

I "fixed" it by setting a min-height on the panel when closing a dump. The min-height is removed when leaving the panel _on purpose_:

![after](https://user-images.githubusercontent.com/1736542/31867054-d01a01cc-b788-11e7-9ef7-8418ae2b3094.gif)

For now I only tested it on Firefox 56 on Arch Linux.

Commits
-------

2e0b263 Fix dump panel hidden when closing a dump
@julienfalque julienfalque deleted the fix-dump-panel-toggling branch November 5, 2017 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants