Skip to content

Commit

Permalink
EZP-32166: Base translation dropdown single selection issue (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Grabowski authored Jan 13, 2021
1 parent 756ca04 commit 0379867
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(global, doc, eZ) {
const CLASS_CUSTOM_DROPDOWN = 'ez-custom-dropdown';
const CLASS_CUSTOM_DROPDOWN_ITEM = 'ez-custom-dropdown__item';
const CLASS_CUSTOM_DROPDOWN_OVERFLOW = 'ez-custom-dropdown--overflow';
const CLASS_ITEMS_HIDDEN = 'ez-custom-dropdown__items--hidden';
const CLASS_ITEMS_POSITION_TOP = 'ez-custom-dropdown__items--position-top';
const CLASS_REMOVE_SELECTION = 'ez-custom-dropdown__remove-selection';
Expand Down Expand Up @@ -209,10 +209,10 @@
selectedItems.forEach((item) => {
item.hidden = false;
});
selectedItems.forEach((item) => {
selectedItems.forEach((item, index) => {
itemsWidth += item.offsetWidth;

if (itemsWidth > selectedItemsContainer.offsetWidth - restrictedAreaItemsContainer) {
if (index !== 0 && itemsWidth > selectedItemsContainer.offsetWidth - restrictedAreaItemsContainer) {
numberOfOverflowItems++;
item.hidden = true;
}
Expand All @@ -221,8 +221,10 @@
if (numberOfOverflowItems) {
selectedItemsOverflow.hidden = false;
selectedItemsOverflow.innerHTML = numberOfOverflowItems;
this.container.classList.add(CLASS_CUSTOM_DROPDOWN_OVERFLOW);
} else {
selectedItemsOverflow.hidden = true;
this.container.classList.remove(CLASS_CUSTOM_DROPDOWN_OVERFLOW);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/bundle/Resources/public/scss/_add-translation.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.ez-translation {
.ez-custom-dropdown {
&__selection-info,
&__items {
&__wrapper {
width: 60%;
}

&__items {
width: 100%;
}
}
}
6 changes: 6 additions & 0 deletions src/bundle/Resources/public/scss/core/_custom.dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,10 @@
margin-bottom: calculateRem(-2px);
}
}

&--overflow {
.ez-custom-dropdown__selected-item {
max-width: calc(100% - #{calculateRem(96px)});
}
}
}

0 comments on commit 0379867

Please # to comment.