FIX: improves positioning of sk in mobile when inside a modal (#9657)

This commit is contained in:
Joffrey JAFFEUX 2020-05-07 09:10:29 +02:00 committed by GitHub
parent 136a545653
commit 87b1d435d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -782,8 +782,10 @@ export default Component.extend(
enabled: window.innerWidth <= 450,
phase: "main",
fn({ state }) {
let { x } = state.elements.reference.getBoundingClientRect();
state.modifiersData.popperOffsets.x = -x + 10;
if (!inModal) {
let { x } = state.elements.reference.getBoundingClientRect();
state.modifiersData.popperOffsets.x = -x + 10;
}
}
},
{
@ -791,7 +793,18 @@ export default Component.extend(
enabled: window.innerWidth <= 450,
phase: "beforeWrite",
fn({ state }) {
state.styles.popper.width = `${window.innerWidth - 20}px`;
if (inModal) {
const innerModal = document.querySelector(
"#discourse-modal div.modal-inner-container"
);
if (innerModal) {
state.styles.popper.width = `${innerModal.clientWidth -
20}px`;
}
} else {
state.styles.popper.width = `${window.innerWidth - 20}px`;
}
}
},
{