Skip to content

fix: open db link inside doucment#281

Merged
appflowy merged 2 commits intomainfrom
fix_open_db_link
Mar 15, 2026
Merged

fix: open db link inside doucment#281
appflowy merged 2 commits intomainfrom
fix_open_db_link

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Mar 15, 2026

Description


Checklist

General

  • I've included relevant documentation or comments for the changes introduced.
  • I've tested the changes in multiple environments (e.g., different browsers, operating systems).

Testing

  • I've added or updated tests to validate the changes introduced for AppFlowy Web.

Feature-Specific

  • For feature additions, I've added a preview (video, screenshot, or demo) in the "Feature Preview" section.
  • I've verified that this feature integrates seamlessly with existing functionality.

Summary by Sourcery

Improve how views and mentioned pages are resolved and opened from documents, especially for database and same-page references.

Bug Fixes:

  • Ensure page documents load only after full view metadata is available so database containers resolve to the correct child view and layout.
  • Open page mentions by navigating directly to the target view (or scrolling within the same page) instead of conditionally opening a modal, preventing incorrect handling for database-linked pages.
  • Avoid rendering empty href wrappers around links when the text is blank to prevent stray clickable areas.

Enhancements:

  • Use full view metadata as the fallback view source, including icon, cover, and extra fields, for more accurate page rendering in the modal.
  • Make mention rendering non-interactive for the hidden overlay span and prevent text selection on the visible mention text for a smoother editor UX.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 15, 2026

Reviewer's Guide

Ensures database-linked views open with correct metadata and navigation behavior, updates mention page interactions to always navigate rather than open a modal, and tightens link/mention rendering to avoid empty href content and unintended pointer events.

Sequence diagram for clicking a page mention in the editor

sequenceDiagram
  actor User
  participant Editor as SlateEditor
  participant MentionPage
  participant Navigator as NavigationService

  User->>Editor: Click mention inline element
  Editor->>MentionPage: onClick event handler
  MentionPage->>MentionPage: Check noAccess
  alt noAccess is true
    MentionPage-->>Editor: Ignore click
  else Same page reference
    MentionPage->>MentionPage: handleScrollToBlock()
    MentionPage->>Editor: Scroll to target block
  else Different page reference
    MentionPage->>Navigator: navigateToView(pageId, blockId) (deferred with timeout)
    Navigator-->>User: Display target view
  end
Loading

Class diagram for updated view and mention components

classDiagram
  class ViewModal {
    +string workspaceId
    +string viewId
    +boolean open
    +function onClose()
    +View fallbackMeta
    +View resolvedView
    +ViewMeta viewMeta
    +function loadView(viewId)
    +function loadPageDoc(viewId)
  }

  class View {
    +string view_id
    +string name
    +ViewLayout layout
    +Icon icon
    +ViewExtra extra
  }

  class ViewExtra {
    +Cover cover
  }

  class ViewMeta {
    +string name
    +Icon icon
    +Cover cover
    +ViewLayout layout
    +string viewId
    +string[] visibleViewIds
    +ViewExtra extra
    +string workspaceId
  }

  class MentionPage {
    +string pageId
    +string blockId
    +MentionType type
    +boolean noAccess
    +View meta
    +string content
    +function handleScrollToBlock()
  }

  class Leaf {
    +LeafProps leaf
    +TextNode text
    +function Leaf(props)
  }

  class MentionLeaf {
    +Mention mention
    +TextNode text
    +function MentionLeaf(mention, text, children)
  }

  ViewModal --> View : uses as fallbackMeta
  ViewModal --> ViewMeta : builds
  View --> ViewExtra : has
  ViewExtra --> Cover : has
  MentionPage --> View : uses as meta
  Leaf --> MentionLeaf : may render
Loading

File-Level Changes

Change Details Files
Load full view metadata as fallback and gate document loading on resolved metadata so database containers open their first child view correctly in ViewModal.
  • Replace minimal FallbackViewMeta with full View type for fallback metadata from ViewService.get
  • Introduce resolvedView as either outline view or full fallback View and use it to derive layout and ViewMeta props
  • Update page document loading effect to wait for resolvedView before calling loadPageDoc
  • Include icon and cover from the fallback View.extra when constructing viewMeta
src/components/app/ViewModal.tsx
Change mention page click behavior to always navigate to the target view (or scroll within the same view) and simplify read-only handling.
  • Remove text prop usage and openPageModal from MentionPage context, relying solely on navigateToView/loadViewMeta/loadView
  • Eliminate readOnly/editor-is-read-only branching so mentions no longer open in a modal based on editability
  • On click, early-return when noAccess, scroll to block when referencing current view, otherwise defer and navigateToView(pageId, blockId) to match desktop behavior
  • Make mention UI non-editable and non-selectable while preserving cursor styling
src/components/editor/components/leaf/mention/MentionPage.tsx
Prevent empty href rendering and avoid pointer interference from mention leaf overlays.
  • Guard Href rendering in Leaf component so it only wraps children when href exists and the text has non-whitespace content
  • Add pointer-events-none to the overlay span in MentionLeaf so it does not intercept mouse events while remaining visually transparent
src/components/editor/components/leaf/Leaf.tsx
src/components/editor/components/leaf/mention/MentionLeaf.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@appflowy appflowy merged commit c1383aa into main Mar 15, 2026
12 of 14 checks passed
@appflowy appflowy deleted the fix_open_db_link branch March 15, 2026 04:01
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.

1 participant