Skip to content

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Nov 25, 2025

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

Adjust mobile workspace drawer layout and behavior for better usability on small screens and side-anchored drawers.

Bug Fixes:

  • Fix mobile side drawer sizing so it respects a configurable top offset and avoids overlapping the header.
  • Ensure mobile workspace list items behave correctly when used outside dropdown menus, including proper click handling.

Enhancements:

  • Allow workspace items and lists to render either as dropdown menu items or as standalone buttons for reuse in different contexts.
  • Improve the current workspace header layout and avatar sizing to align better with mobile and desktop designs.
  • Refine mobile folder top bar spacing and alignment for a cleaner layout on small screens.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 25, 2025

Reviewer's Guide

Refactors workspace list items to be reusable outside dropdown menus and adjusts the mobile drawer/top bar layout so the workspace drawer behaves correctly on mobile, including top offset handling and responsive widths.

Sequence diagram for mobile workspace selection via drawer

sequenceDiagram
  actor MobileUser
  participant MobileTopBar
  participant MobileDrawer
  participant MobileFolder
  participant MobileWorkspaces
  participant WorkspaceList
  participant WorkspaceItem

  MobileUser->>MobileTopBar: tapFolderButton()
  MobileTopBar->>MobileDrawer: toggleDrawer(true)
  MobileDrawer-->>MobileUser: displayWorkspaceDrawer(topOffset)

  MobileDrawer->>MobileFolder: render()
  MobileFolder->>MobileWorkspaces: render()
  MobileWorkspaces->>WorkspaceList: render(useDropdownItem=false)
  WorkspaceList->>WorkspaceItem: renderAsButton()

  MobileUser->>WorkspaceItem: tapWorkspaceButton()
  WorkspaceItem->>WorkspaceItem: handleSelect()
  alt sameWorkspace
    WorkspaceItem-->>MobileUser: noChange()
  else differentWorkspace
    WorkspaceItem->>MobileWorkspaces: onChange(selectedId)
    MobileWorkspaces->>WorkspaceList: updateCurrentWorkspace()
    MobileWorkspaces->>MobileDrawer: onClose()
    MobileDrawer-->>MobileUser: hideWorkspaceDrawer()
  end
Loading

Class diagram for updated workspace components and mobile drawer

classDiagram
  class WorkspaceItem {
    +boolean showActions
    +Workspace workspace
    +string currentWorkspaceId
    +string changeLoading
    +function onChange(selectedId)
    +function onUpdate(workspace)
    +function onDelete(workspace)
    +function onLeave(workspace)
    +boolean useDropdownItem
    +handleSelect()
  }

  class WorkspaceList {
    +string currentWorkspaceId
    +string changeLoading
    +Workspace[] defaultWorkspaces
    +boolean showActions
    +function onChange(selectedId)
    +function onUpdate(workspace)
    +function onDelete(workspace)
    +function onLeave(workspace)
    +boolean useDropdownItem
  }

  class CurrentWorkspace {
    +UserWorkspaceInfo userWorkspaceInfo
    +Workspace selectedWorkspace
    +function onChangeWorkspace(selectedId)
    +AvatarSize avatarSize
    +boolean changeLoading
  }

  class MobileWorkspaces {
    +boolean changeLoading
    +function onClose()
    +handleChange(selectedId)
  }

  class MobileDrawer {
    +ReactNode children
    +ReactElement triggerNode
    +DrawerAnchor anchor
    +number swipeAreaWidth
    +number swipeAreaHeight
    +number maxHeight
    +boolean showPuller
    +number topOffset
    +function onOpen()
    +function onClose()
    +boolean open
    +toggleDrawer(open)
    +paperStyle
  }

  class MobileTopBar {
    +UIVariant variant
    +boolean openFolder
    +boolean openMore
    +number folderDrawerWidth
    +handleOpenFolder()
    +handleCloseFolder()
    +handleOpenMore()
    +handleCloseMore()
  }

  class MobileFolder {
    +function onClose()
  }

  class Avatar {
    +AvatarShape shape
    +AvatarSize size
  }

  class AvatarSize {
    <<enumeration>>
    xs
    sm
    md
    xl
  }

  WorkspaceList *-- WorkspaceItem
  MobileWorkspaces *-- WorkspaceList
  MobileFolder *-- MobileWorkspaces
  MobileTopBar *-- MobileDrawer
  MobileDrawer *-- MobileFolder

  CurrentWorkspace *-- Avatar
  WorkspaceItem *-- Avatar
Loading

File-Level Changes

Change Details Files
Make WorkspaceItem/WorkspaceList usable both as dropdown items and as standalone buttons (for mobile drawer usage).
  • Add a useDropdownItem prop to WorkspaceItem to switch between DropdownMenuItem and a styled button wrapper
  • Extract shared workspace row content into a reusable JSX fragment and share it between dropdown and button modes
  • Introduce a memoized handleSelect callback for workspace switching and reuse it for both click/select handlers
  • Propagate the useDropdownItem flag through WorkspaceList to WorkspaceItem
  • Update MobileWorkspaces to render workspace items as full-width buttons instead of dropdown entries
src/components/app/workspaces/WorkspaceItem.tsx
src/components/app/workspaces/WorkspaceList.tsx
src/components/app/workspaces/MobileWorkspaces.tsx
Improve mobile drawer behavior with a configurable top offset and responsive width for the folder drawer.
  • Add a topOffset prop to MobileDrawer and apply it to side-anchored drawers by adjusting Paper style.top and height computations
  • Refactor MobileDrawer PaperProps.style into a reusable paperStyle object including width, height, and maxHeight
  • In MobileTopBar, derive folderDrawerWidth via useMemo based on window.innerWidth and platform, avoiding SSR issues and capping width on non-mobile
  • Pass folderDrawerWidth and HEADER_HEIGHT-based topOffset into MobileDrawer for the folder menu trigger
src/components/_shared/mobile-drawer/MobileDrawer.tsx
src/components/_shared/mobile-topbar/MobileTopBar.tsx
Adjust mobile workspace header layout and current workspace avatar sizing for better alignment in the mobile drawer.
  • Change CurrentWorkspace avatarSize prop to accept named size variants instead of a numeric value and wrap content in a flex row that enforces minimum height and alignment
  • Update Workspaces to pass the new avatarSize string variant ('sm')
  • Tweak MobileFolder header layout to align MobileWorkspaces and MobileMore with flex-start and spacing suitable for the new button-style list
src/components/app/workspaces/CurrentWorkspace.tsx
src/components/app/workspaces/Workspaces.tsx
src/components/_shared/mobile-topbar/MobileFolder.tsx

Possibly linked issues

  • #FR: PR widens and offsets the mobile drawer and makes workspace items full-width buttons, improving sidebar touch areas.

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 there - I've reviewed your changes - here's some feedback:

  • In MobileTopBar, folderDrawerWidth is computed once from window.innerWidth without listening to resize/orientation changes, so consider adding a resize listener or using a hook to recalculate the drawer width when the viewport size changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In MobileTopBar, `folderDrawerWidth` is computed once from `window.innerWidth` without listening to resize/orientation changes, so consider adding a resize listener or using a hook to recalculate the drawer width when the viewport size changes.

## Individual Comments

### Comment 1
<location> `src/components/_shared/mobile-topbar/MobileTopBar.tsx:25` </location>
<code_context>
  const isMobile = getPlatform().isMobile;

</code_context>

<issue_to_address>
**suggestion (code-quality):** Prefer object destructuring when accessing and using properties. ([`use-object-destructuring`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/use-object-destructuring))

```suggestion
  const {isMobile} = getPlatform();
```

<br/><details><summary>Explanation</summary>Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the [Airbnb Javascript Style Guide](https://airbnb.io/javascript/#destructuring--object)
</details>
</issue_to_address>

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.

function MobileTopBar({ variant }: { variant?: UIVariant }) {
const [openFolder, setOpenFolder] = React.useState(false);
const [openMore, setOpenMore] = React.useState(false);
const isMobile = getPlatform().isMobile;
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const isMobile = getPlatform().isMobile;
const {isMobile} = getPlatform();


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

@appflowy appflowy merged commit d3810b8 into main Nov 25, 2025
12 checks passed
@appflowy appflowy deleted the fix_mobile_drawer branch November 25, 2025 14:53
josue693 pushed a commit to josue693/AppFlowy-Web that referenced this pull request Dec 21, 2025
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