Fix issue with mention list wrong content (#1183)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-03-21 09:19:26 +07:00 committed by GitHub
parent 65ddacd444
commit 1993180fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,23 +83,32 @@
const rect = clientRect() const rect = clientRect()
const docW = document.body.clientWidth const docW = document.body.clientWidth
let tempStyle = '' let tempStyle = ''
if (rect.top < 292) // 20rem - 1.75rem if (rect.top < 292) { // 20rem - 1.75rem
tempStyle = `top: calc(${rect.bottom}px + .75rem); max-heigth: calc(100vh - ${rect.bottom}px - 1.75rem); ` tempStyle = `top: calc(${rect.bottom}px + .75rem); max-heigth: calc(100vh - ${rect.bottom}px - 1.75rem); `
else tempStyle = `bottom: calc(100vh - ${rect.top}px + .75rem); max-heigth: calc(${rect.top}px - 1.75rem); ` } else {
if (docW - rect.left > 452) // 30rem - 1.75rem tempStyle = `bottom: calc(100vh - ${rect.top}px + .75rem); max-heigth: calc(${rect.top}px - 1.75rem); `
}
if (docW - rect.left > 452) { // 30rem - 1.75rem
tempStyle += `left: ${rect.left}px;` tempStyle += `left: ${rect.left}px;`
else tempStyle += `right: calc(100vw - ${rect.right}px);` } else {
tempStyle += `right: calc(100vw - ${rect.right}px);`
}
style = tempStyle style = tempStyle
} }
let style = 'visibility: hidden' let style = 'visibility: hidden'
$: if (popup) updateStyle() $: if (popup) updateStyle()
async function updateItems (category: ObjectSearchCategory, query: string): Promise<void> { async function updateItems (updateCategory: ObjectSearchCategory, query: string): Promise<void> {
const f = await getResource(category.query) const f = await getResource(updateCategory.query)
items = await f(client, query)
if (selected > items.length) { const result = await f(client, query)
selected = 0 // We need to sure, results we return is for proper category.
if (updateCategory._id === category._id) {
items = result
if (selected > items.length) {
selected = 0
}
} }
} }
$: updateItems(category, query) $: updateItems(category, query)