quartz icon indicating copy to clipboard operation
quartz copied to clipboard

Components breaks when using with different view.

Open aster-hu opened this issue 2 years ago • 6 comments

Describe the bug When Component.Search() exists in both left and right sidebar in quartz.layout.ts, the search bar on the right side didn't work.

To Reproduce Steps to reproduce the behavior:

  1. Clone the quartz repo
  2. Add search bar on the right side as below
right: [
    Component.Search(), // add search bar on the right too
    Component.Graph(),
    Component.DesktopOnly(Component.TableOfContents()),
    Component.Backlinks(),
  ],
  1. Build and preview
  2. Click the search bar on the right and it would not work

Expected behavior The search bar should work even when it shows on both sidebar.

Usually it's no big deal because only one is needed in most case, but I was trying to achieve different layout for mobile and desktop like below, which triggers the issue.

left: [
    Component.PageTitle(),
    Component.MobileOnly(Component.Spacer()),
    Component.MobileOnly(Component.Search()),
....

  right: [
    Component.DesktopOnly(Component.Search()),
    Component.Graph(),
...

Desktop (please complete the following information):

  • Device: Mac Mini M2
  • OS: Ventura 13.5.2
  • Browser: Safari, Chrome

aster-hu avatar Nov 03 '23 02:11 aster-hu

I think for viewing you should resolve to use custom.scss instead.

You can update how components view based on @media query.

I will close this since this is not really a bug, rather a usage.

aarnphm avatar Feb 02 '24 04:02 aarnphm

@aarnphm this is an actual bug as we kinda do assume that components are singletons and maybe we should revisit that assumption?

jackyzha0 avatar Feb 02 '24 04:02 jackyzha0

Hmm, FWIW, assuming singleton should be ok here, since multiple searches don't make sense.

What do you have in mind?

aarnphm avatar Feb 02 '24 13:02 aarnphm

I think specifically on getting search in various places depending on layout is a common usecase, not sure what the best way to solve this is though lol

jackyzha0 avatar Feb 02 '24 17:02 jackyzha0

Hmm you are right, I'm doing this for Explorer

// components for pages that display lists of pages  (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
  beforeBody: [Component.ArticleTitle()],
  left: [
    Component.MobileOnly(Component.Explorer()),
    Component.MobileOnly(Component.Spacer()),
    Component.Search(),
    Component.Darkmode(),
    Component.DesktopOnly(Component.Explorer({ filterFn: explorerFilterFn })),
  ],
  right: [],
}

aarnphm avatar Feb 02 '24 18:02 aarnphm

Does any workaround exist for this? I'm having the same issue for other components where I want to display them differently based on "Desktop" or "Mobile" user.

eledah avatar May 21 '24 05:05 eledah