Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iframe Answers Map/List toggle button on Mobile Error #1150

Merged
merged 5 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions static/js/theme-map/VerticalFullPageMapOrchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,42 +205,42 @@ class VerticalFullPageMapOrchestrator extends ANSWERS.Component {
});
this.setupMobileBreakpointListener();
this.addMapComponent();
this.setFixedHeightsOnAndroid();
}

/**
* On Android browsers, opening up the keyboard will shift the contents of the entire page up,
* moving the map center, and thereby causing a searchOnMapMove to be triggered.
* The search response would then cause the page to update,
* and close the keyboard, making it impossible to actually type anything into the searchbar.
*
* Setting a fixed height on elements like .Answers-mapWrapper prevents the keyboard from shifting the content
* of the page.
*/
setFixedHeightsOnAndroid() {
if (!this.isMobile() || !/Android/i.test(navigator.userAgent)) {
return;
}

setFixedHeight('.Answers-mapWrapper')

function getSingleElement(selector) {
const els = document.querySelectorAll(selector);
if (els.length === 0) {
console.error(`No ${selector} found, unable to set fixed height for the full page map.`);
} else if (els.length > 1) {
console.error(
`Multiple elements for ${selector} found, expected only 1, not setting fixed height for the full page map.`);
} else {
return els[0];
}
}

function setFixedHeight(selector) {
const el = getSingleElement(selector)
el.style.height = `${el.scrollHeight}px`
}
}
//NOTE: set min-height for js-answersMap instead to prevent keyboard from shifting the page
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't need this code we can delete it instead of commenting it out

// /**
// * On Android browsers, opening up the keyboard will shift the contents of the entire page up,
// * moving the map center, and thereby causing a searchOnMapMove to be triggered.
// * The search response would then cause the page to update,
// * and close the keyboard, making it impossible to actually type anything into the searchbar.
// *
// * Setting a fixed height on elements like .Answers-mapWrapper prevents the keyboard from shifting the content
// * of the page.
// */
// setFixedHeightsOnAndroid() {
// if (!this.isMobile() || !/Android/i.test(navigator.userAgent)) {
// return;
// }

// setFixedHeight('.Answers-mapWrapper')

// function getSingleElement(selector) {
// const els = document.querySelectorAll(selector);
// if (els.length === 0) {
// console.error(`No ${selector} found, unable to set fixed height for the full page map.`);
// } else if (els.length > 1) {
// console.error(
// `Multiple elements for ${selector} found, expected only 1, not setting fixed height for the full page map.`);
// } else {
// return els[0];
// }
// }

// function setFixedHeight(selector) {
// const el = getSingleElement(selector)
// el.style.height = `${el.scrollHeight}px`
// }
// }

/**
* Properly set CSS classes for mobile and desktop
Expand Down
2 changes: 1 addition & 1 deletion templates/vertical-full-page-map/markup/map.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div id="js-answersMap" class="Answers-map js-answersMap" dir="ltr"></div>
<div id="js-answersMap" class="Answers-map js-answersMap" style="min-height:1px" dir="ltr"></div>