Skip to content

Commit

Permalink
Merge pull request #35031 from dimagi/rc/fix-location-name-truncation…
Browse files Browse the repository at this point in the history
…-bug

account for mobile worker tabs when handling location names
  • Loading branch information
Robert-Costello authored Aug 26, 2024
2 parents ff76b3e + 18fcdce commit 2e6d708
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion corehq/apps/locations/static/locations/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ hqDefine("locations/js/widgets", [

function truncateLocationName(name, select) {
const nameWidthPixels = getSelectTextWidth(name, select);
const containerWidthPixels = select.parent().width();
const basicInfoTabActive = $('#basic-info').hasClass('active');
let containerWidthPixels = select.parent().width();

// Select is hidden on locations tab. Calculate width from visible select.
if (basicInfoTabActive) {
const visibleSelect = $('#basic-info').find('.controls > .select')[0];
if (!visibleSelect) {
return name;
}
containerWidthPixels = $(visibleSelect).parent().width();
// Default to select2 setting for overflow
} else if (containerWidthPixels < 0) {
return name;
}
let truncatedName;
if (nameWidthPixels > containerWidthPixels) {
// Conservative calc of the number of chars that will fit the container
Expand Down

0 comments on commit 2e6d708

Please sign in to comment.