Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structure - Support automatically showing multiple views by default when opening a document #7844

Open
eliasm307 opened this issue Nov 19, 2024 · 0 comments

Comments

@eliasm307
Copy link

Is your feature request related to a problem? Please describe.

The sanity studio supports defining multiple views for a document (see https://www.sanity.io/docs/create-custom-document-views-with-structure-builder#b0873d62a06a) which allows CMS admin users to define visual previews of document changes directly in the studio. An example of this is shown on the linked documentation page, ie the form view is opened on the left and a custom view is shown on the right (imagine this is a nice visual preview):
image

This is good, however, the issue is that by default, only a single view is shown initially when a user opens a document in the studio (ie the form view or maybe the first defined view, I haven't tried changing order). This means CMS content editor users have to go through the repetitive process of duplicating the document window and then opening the custom/preview view on the other window, to allow them to see the visual result of changes in real-time.

The repetitive process to setup the form and a preview side-by-side likely means users make changes in the form view and then switch back and forth to a preview view to see changes which is inconvenient. Also, since the process to show previews side by side requires knowledge of the ability to duplicate windows, it is not very accessible to non-technical people, and so in some cases it's the user's inconvenience due to not knowing there is a better way.

Describe the solution you'd like

Instead of relying on CMS editor users to setup side-by-side views, it would be good if CMS admins could configure (via the StructureBuilder API from the sanity/structure package) certain views (multiple) to be shown by default when a user opens a document, where it is likely to be beneficial to editor users.

I do not know the best solution for this but my idea is to provide the ability to define default views/windows via a new API e.g.

const formView = S.view.form();
const preview1View = S.view.component(Preview1Component);
const preview2View = S.view.component(Preview2Component);

S.document()
  // define all available views
  .views([formView, preview1View, preview2View])

  // new API - define views that are shown by default in separate windows
  // views are shown in the defined order side-by-side horizontally
  .defaultWindows([ formView, preview1View ])

For the example above, this would show two windows side by side with the form view on the left and the preview1 view on the right. The windows would still have the normal UI so a user can then customise e.g. open different views (like preview2) on the different windows, duplicate more windows etc but the benefit is that there is a default experience which is much more accessible and can be defined where it makes sense.

Describe alternatives you've considered

No alternatives as no API is exposed to open/duplicate windows. So just been relying on users manually opening previews.

However alternative solutions could be to define certain views as opening in a new window, so the document opens as normal with the form view, then when a user clicks the preview view, a new window is opened automatically to the side and leaves the form view open. However, I did not like this idea because:

  • what happens if the user clicks the preview again? does it open in a new window again? its difficult to know what a user actually wants to do in this case so there is a risk of an annoying UX if the behaviour is not the intention e.g. the user just wants to open the view in the same window
  • this is still a bit "hidden" as the user needs to know to click the preview to know that the preview exists. Personally, I prefer for the preview to be more explicit

Additional context

N/A

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

No branches or pull requests

1 participant