8000 Fixed a bug when CMS would incorrectly highlight plugin content · django-cms/django-cms@65a3127 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65a3127

Browse files
committed
Fixed a bug when CMS would incorrectly highlight plugin content
Invisible elements were reporting 0/0 offset which would essentially scroll the page higher and higher every time you press shift while hovering over plugin that has invisible elements
1 parent 7a915f5 commit 65a3127

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
with multiple page types per site.
55
* Fixed a bug which prevented toolbar js from working correctly when rendered
66
before toolbar.
7+
* Fixed a bug where CMS would incorrectly highlight plugin content when plugin
8+
contains invisible elements
79

810

911
=== 3.5.0 (2018-01-31) ===

cms/static/cms/js/dist/3.5.0/bundle.toolbar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cms/static/cms/js/modules/cms.plugins.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,12 @@ Plugin._highlightPluginContent = function _highlightPluginContent(
20762076
var mr = parseInt(el.css('margin-right'), 10);
20772077
var mt = parseInt(el.css('margin-top'), 10);
20782078
var mb = parseInt(el.css('margin-bottom'), 10);
2079+
var width = el.outerWidth();
2080+
var height = el.outerHeight();
2081+
2082+
if (width === 0 && height === 0) {
2083+
return;
2084+
}
20792085

20802086
if (isNaN(ml)) {
20812087
ml = 0;
@@ -2092,12 +2098,16 @@ Plugin._highlightPluginContent = function _highlightPluginContent(
20922098

20932099
positions.push({
20942100
x1: offset.left - ml,
2095-
x2: offset.left + el.outerWidth() + mr,
2101+
x2: offset.left + width + mr,
20962102
y1: offset.top - mt,
2097-
y2: offset.top + el.outerHeight() + mb
2103+
y2: offset.top + height + mb
20982104
});
20992105
});
21002106

2107+
if (positions.length === 0) {
2108+
return;
2109+
}
2110+
21012111
// turns out that offset calculation will be off by toolbar height if
21022112
// position is set to "relative" on html element.
21032113
var html = $('html');

0 commit comments

Comments
 (0)
0