Skip to content

fix: restore document list pagination and scope detail scrolling - #8302

Merged
wangdan-fit2cloud merged 2 commits into
v3from
pr@v3@fix_page
Dec 4, 2026
Merged

wangdan-fit2cloud merged 2 commits into
v3from
pr@v3@fix_page

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

perf: Readme
fix: restore document list pagination and scope detail scrolling

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 2b15bbd into v3 Dec 4, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_page branch December 4, 2026 10:18

const documentQuery = ref<Dict<unknown>>({})
const orderBy = ref<string>()
const creatorOptions = ref<OptionItem<string>[]>([])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The diff is generally reasonable, but there are several things to check/fix. I’m assuming pagination-return handles router/history-state storage correctly; without its implementation, some risks below are conditional.

Potential issues

  1. Unhandled promise rejection

    void router.push(detailLocation).then((failure) => {
      if (!failure) saveDocumentPagination(...)
    })

    There is no .catch(). If router.push rejects unexpectedly, or saveDocumentPagination throws inside .then, this becomes an unhandled rejection. Prefer async/await with try/catch, or add .catch().

  2. Saved pagination is not validated

    currentPage: savedPagination?.currentPage ?? 1,
    pageSize: savedPagination?.pageSize ?? 20,

    The saved values come from browser history/storage and can be stale or invalid. Validate:

    • currentPage is an integer >= 1
    • pageSize is one of the allowed page-size options
    • after total is loaded, clamp currentPage to the last valid page and refetch if needed

    Otherwise users can land on an empty page after deleting documents or changing filters.

  3. Restored page can exceed the actual total
    total is reset to 0, and the saved currentPage is applied before data is loaded. If the saved page no longer exists, the table may render empty. After fetch, do something like:

    const maxPage = Math.max(1, Math.ceil(total / pageSize))
    if (currentPage > maxPage) currentPage = maxPage
  4. Location key normalization
    detailLocation is passed to both router.push and saveDocumentPagination. Vue Router may normalize query/params. If pagination-return does not resolve the location itself, use the resolved path for the storage key:

    const detailFullPath = router.resolve(detailLocation).fullPath

    Otherwise the saved key may not exactly match the route later read by takeDocumentPagination.

  5. Sharing route.query by reference

    query: route.query

    It is safer to clone it:

    query: { ...route.query }

    This avoids accidental coupling to the reactive route object.

  6. KeepAlive / component reuse

    const savedPagination = takeDocumentPagination(router)

    This runs only during setup(). If the list component is kept alive or reused when returning from the detail page, the saved pagination will not be consumed. In that case, move restoration into onActivated() or a route watcher.

  7. Scoping of saved pagination
    Make sure saveDocumentPagination / takeDocumentPagination are scoped by knowledge base / resource / list route. Otherwise pagination from one document list could leak into another.

  8. void router.push(...).then(...) is misleading
    It works, but the void makes it look like errors are intentionally ignored. A clearer form would be:

    router.push(detailLocation)
      .then((failure) => { ... })
      .catch((error) => { ... })

    or better:

    async function handleOpenParagraph(...) {
      ...
      try {
        const failure = await router.push(detailLocation)
        if (failure) return
        saveDocumentPagination(router, listLocation, detailLocation, { currentPage, pageSize })
      } catch (error) {
        // log/handle
      }
    }

Minor note

handleOpenParagraph references paginationConfig before its declaration, but since the function is only called after setup completes, this is not a runtime TDZ issue. It is still slightly harder to read; declaring paginationConfig earlier might be cleaner.

Recommended fix summary

  • Add error handling around router.push and saveDocumentPagination.
  • Validate/normalize restored currentPage and pageSize.
  • Clamp the restored page after total is known.
  • Ensure the saved detail-location key is resolved/normalized consistently.
  • Clone route.query.
  • Use onActivated/route watcher if the list page can be kept alive.
  • Ensure pagination storage is scoped to the correct knowledge/resource list.

.resource-detail-layout :deep(main > .el-scrollbar > .el-scrollbar__wrap > .el-scrollbar__view:has(> .mk-scrollbar-fill-height)) {
height: 100%;
}
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The diff is syntactically valid, but there are several fragility/compatibility concerns:

  1. :has() browser support

    • :has() is not supported in older browser versions. If the project still supports older Safari/Firefox/enterprise browsers, this layout rule will silently fail.
    • PostCSS/autoprefixer generally won’t transpile :has(). Use a fallback or avoid :has() if support is required.
  2. Tight coupling to Element Plus / MkViewLayout internal DOM

    • This selector depends on the exact DOM chain:
      main > .el-scrollbar > .el-scrollbar__wrap > .el-scrollbar__view.
    • Any internal change in MkViewLayout or Element Plus can break it silently.
    • Prefer exposing a prop/class from MkViewLayout or applying a dedicated class to the scrollbar view instead of piercing internal implementation details.
  3. Assumption that class="resource-detail-layout" lands on the expected root

    • This works only if MkViewLayout has a single root element and normal attribute fallthrough.
    • If it uses a fragment root, inheritAttrs: false, or redirects attrs, the selector may not match.
  4. height: 100% may be ineffective

    • height: 100% only resolves correctly if the parent chain has a definite height.
    • In flex layouts, you often need flex: 1; min-height: 0; rather than only height: 100%.
    • Verify this does not create nested scrollbars or clip content.
  5. :has(> .mk-scrollbar-fill-height) is direct-child-only

    • If an extra wrapper is introduced around .mk-scrollbar-fill-height, the rule stops applying.
    • Confirm this strict relationship is intentional.
  6. Potentially broad selector

    • .resource-detail-layout :deep(main > ...) can match nested main elements under the layout.
    • If nested layouts are possible, consider a tighter selector or a dedicated class for the target scrollbar view.

Suggested improvement: avoid :has() and internal DOM coupling by having MkViewLayout support a “fill height” class/prop, or by placing a semantic class directly on the scrollbar view. If keeping the current approach, add a browser-support fallback and document that the selector depends on Element Plus internals.

Minor: the CSS comment is in Chinese; consider matching the project’s comment-language convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants