Skip to content

Commit

Permalink
fix: set maxheight for layer search (#1886)
Browse files Browse the repository at this point in the history
* Set maxheight for layer search

* Update _awesomplete.theme.scss

* Update _awesomplete.theme.scss

* Update _awesomplete.base.scss

* Fix for search as well

* Update search.js

* Final adjustments
  • Loading branch information
jokd authored Nov 3, 2023
1 parent b955174 commit 907a77d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 4 additions & 2 deletions scss/externs/_awesomplete.base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
position: absolute;
top: 40px;
z-index: 1;
overflow-y: auto;
}

.awesomplete.black > ul {
Expand All @@ -39,14 +40,15 @@
left: 0px;
list-style: none;
margin: 0;
min-width: 180px;
max-width: 100%;
width: 100%;
min-width: unset;
overflow-wrap: break-word;
padding: 0;
position: absolute;
top: auto;
bottom: 100%;
z-index: 9999999;
overflow-y: auto;
}

.awesomplete > ul:empty {
Expand Down
7 changes: 0 additions & 7 deletions scss/externs/_awesomplete.theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,3 @@
.awesomplete li[aria-selected='true'] mark {
background-color: $search-hover-backround;
}

&[class*=#{$media-l-m}] {
.awesomplete > ul {
max-width: calc(100% + 2rem);
min-width: calc(100% + 2rem);
}
}
2 changes: 1 addition & 1 deletion src/controls/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ const Legend = function Legend(options = {}) {
return suggestionValue.toLowerCase().includes(userInput.toLowerCase()) ? suggestionValue : false;
}
});

awesomplete.ul.style.maxHeight = `${calcMaxHeight(getTargetHeight()) / 2}px`;
input.parentNode.classList.add('black');
input.parentNode.classList.add('grow');
input.addEventListener('keyup', (e) => {
Expand Down
3 changes: 3 additions & 0 deletions src/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ const Search = function Search(options = {}) {

function initAutocomplete() {
const input = document.getElementsByClassName('o-search-field')[0];
const mapEl = viewer.getMap().getTargetElement();
const listHeight = mapEl.offsetHeight / 2;

awesomplete = new Awesomplete('.o-search-field', {
minChars: minLength,
Expand All @@ -324,6 +326,7 @@ const Search = function Search(options = {}) {
return suggestionValue.toLowerCase().includes(userInput.toLowerCase()) ? suggestionValue : false;
}
});
awesomplete.ul.style.maxHeight = `${listHeight}px`;

const handler = function func(list) {
awesomplete.list = list;
Expand Down

0 comments on commit 907a77d

Please sign in to comment.