Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9724e8b

Browse filesBrowse files
committed
bug #22968 [Profiler] Fix text selection & click on file links on exception pages (ogizanagi)
This PR was squashed before being merged into the 3.3 branch (closes #22968). Discussion ---------- [Profiler] Fix text selection & click on file links on exception pages | Q | A | ------------- | --- | Branch? | 3.3 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #22957, #22978 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A I don't really know the purpose of this css rule here, but I admit it's quite frustrating not to be able to select something here. This PR also prevents the following annoying behavior (selecting text collapses/uncollapses traces): ![mai-30-2017 18-26-29](https://cloud.githubusercontent.com/assets/2211145/26593977/3afbc510-4566-11e7-9114-8934ba6126a2.gif) About the trick used, I think the browser support is safe enough: https://caniuse.com/#search=window.getSelection EDIT: new commit added which allows to fix #22978 Commits ------- 8618399 [Profiler] Fix clicking on links inside toggle ff6151b [Profiler] Fix text selection on exception pages
2 parents 5473373 + 8618399 commit 9724e8b
Copy full SHA for 9724e8b

File tree

4 files changed

+26
-2
lines changed
Filter options

4 files changed

+26
-2
lines changed

‎src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@
478478
addEventListener(toggles[i], 'click', function(e) {
479479
e.preventDefault();
480480
481+
if ('' !== window.getSelection().toString()) {
482+
/* Don't do anything on text selection */
483+
return;
484+
}
485+
481486
var toggle = e.target || e.srcElement;
482487
483488
/* needed because when the toggle contains HTML contents, user can click */
@@ -507,6 +512,14 @@
507512
var altContent = toggle.getAttribute('data-toggle-alt-content');
508513
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
509514
});
515+
516+
/* Prevents from disallowing clicks on links inside toggles */
517+
var toggleLinks = document.querySelectorAll('.sf-toggle a');
518+
for (var i = 0; i < toggleLinks.length; i++) {
519+
addEventListener(toggleLinks[i], 'click', function(e) {
520+
e.stopPropagation();
521+
});
522+
}
510523
}
511524
}
512525
};

‎src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ header .container { display: flex; justify-content: space-between; }
8989
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }
9090

9191
.trace + .trace { margin-top: 30px; }
92-
.trace-head { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
9392
.trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; }
9493
.trace-head .trace-namespace { color: #999; display: block; font-size: 13px; }
9594
.trace-head .icon { position: absolute; right: 0; top: 0; }

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@
478478
addEventListener(toggles[i], 'click', function(e) {
479479
e.preventDefault();
480480
481+
if ('' !== window.getSelection().toString()) {
482+
/* Don't do anything on text selection */
483+
return;
484+
}
485+
481486
var toggle = e.target || e.srcElement;
482487
483488
/* needed because when the toggle contains HTML contents, user can click */
@@ -508,6 +513,14 @@
508513
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
509514
});
510515
}
516+
517+
/* Prevents from disallowing clicks on links inside toggles */
518+
var toggleLinks = document.querySelectorAll('.sf-toggle a');
519+
for (var i = 0; i < toggleLinks.length; i++) {
520+
addEventListener(toggleLinks[i], 'click', function(e) {
521+
e.stopPropagation();
522+
});
523+
}
511524
}
512525
};
513526
})();

‎src/Symfony/Component/Debug/ExceptionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ public function getStylesheet(FlattenException $exception)
316316
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }
317317
318318
.trace + .trace { margin-top: 30px; }
319-
.trace-head { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
320319
.trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; }
321320
322321
.trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; }

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.