Update ui.checkOverflow to only apply to iD's subelements and to account for empty selections

This commit is contained in:
Quincy Morgan
2020-10-29 10:17:50 -04:00
parent e83235df54
commit d70f2e2e0f
+7 -5
View File
@@ -548,19 +548,21 @@ export function uiInit(context) {
delete _needWidth[selector];
}
var element = d3_select(selector);
var scrollWidth = element.property('scrollWidth');
var clientWidth = element.property('clientWidth');
var selection = context.container().select(selector);
if (selection.empty()) return;
var scrollWidth = selection.property('scrollWidth');
var clientWidth = selection.property('clientWidth');
var needed = _needWidth[selector] || scrollWidth;
if (scrollWidth > clientWidth) { // overflow happening
element.classed('narrow', true);
selection.classed('narrow', true);
if (!_needWidth[selector]) {
_needWidth[selector] = scrollWidth;
}
} else if (scrollWidth >= needed) {
element.classed('narrow', false);
selection.classed('narrow', false);
}
};