Skip to content

Commit

Permalink
fix: Disappearing children
Browse files Browse the repository at this point in the history
close #4814
  • Loading branch information
tiensonqin committed Apr 5, 2022
1 parent 47445e4 commit 2b0a560
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -40,3 +40,5 @@ charlie/
docker
android/app/src/main/assets/capacitor.plugin.json
ios/App/App/capacitor.config.json

startup.png
21 changes: 21 additions & 0 deletions e2e-tests/editor.spec.ts
Expand Up @@ -65,6 +65,27 @@ test('hashtag and quare brackets in same line #4178', async ({ page }) => {
)
})

test('disappeared children #4814', async ({ page }) => {
await createRandomPage(page)

await page.type('textarea >> nth=0', 'parent')
await enterNextBlock(page)
await page.press('textarea >> nth=0', 'Tab')

for (let i = 0; i < 6; i++) {
await page.type('textarea >> nth=0', i.toString())
await enterNextBlock(page)
}

// collapse
await page.press('textarea >> nth=0', 'Control+ArrowUp')

// expand
await page.press('textarea >> nth=0', 'Control+ArrowDown')

await page.waitForSelector('.ls-block >> nth=6') // 7 blocks
})

// FIXME: ClipboardItem is not defined when running with this test
// test('copy & paste block ref and replace its content', async ({ page }) => {
// await createRandomPage(page)
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/utils.ts
Expand Up @@ -81,6 +81,7 @@ export async function lastBlock(page: Page): Promise<Locator> {
export async function enterNextBlock(page: Page): Promise<Locator> {
let blockCount = await page.locator('.page-blocks-inner .ls-block').count()
await page.press('textarea >> nth=0', 'Enter')
await page.waitForTimeout(10)
await page.waitForSelector(`.ls-block >> nth=${blockCount} >> textarea`, { state: 'visible' })
return page.locator('textarea >> nth=0')
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/frontend/db/model.cljs
Expand Up @@ -671,7 +671,9 @@
(remove nil?))]
[(zipmap (mapv :db/id blocks) blocks)
(zipmap (mapv :db/id @result) @result)]))
limit (if (and result @result) (+ (count @result) 5) limit)
limit (if (and result @result)
(max (+ (count @result) 5) limit)
limit)
outliner-op (get-in tx-report [:tx-meta :outliner-op])
blocks (build-paginated-blocks-from-cache repo-url tx-report result outliner-op page-id block-id tx-block-ids scoped-block-id)
blocks (or blocks
Expand Down

0 comments on commit 2b0a560

Please sign in to comment.