8000 bug #22968 [Profiler] Fix text selection & click on file links on exc… · symfony/symfony@9724e8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9724e8b

Browse 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

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

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

Lines 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

Lines 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

Lines 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

Lines 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