Skip to content

Conversation

@shekharnwagh
Copy link
Contributor

Description

Adds a new collaboration mode picker component in the editor toolbar that lets users switch between View mode and Edit mode.

Currently its just an UI without any functionality.

Depends on gutenberg PR - WordPress/gutenberg#73196

Screenshots

Screenshot 2025-11-13 at 12 48 38 AM
Collaboration mode picker expanded

Screen Recording

ElectedModesUI_v1.mp4

Adds a new collaboration mode picker component in the editor toolbar
that lets users switch between View mode and Edit mode.

Currently its just an UI without any functionality.
@shekharnwagh shekharnwagh self-assigned this Nov 12, 2025
@shekharnwagh shekharnwagh requested a review from a team as a code owner November 12, 2025 19:29

import '@/components/collaboration-mode/collaboration-mode-picker.scss';

type CollaborationModeType = 'view' | 'edit';
Copy link
Contributor

@ingeniumed ingeniumed Nov 12, 2025

Choose a reason for hiding this comment

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

This'd be better in the settings store imo. It can be set to edit by default, and hidden outside of development mode.

We should ideally have an enum that's exported, and re-usable outside this component. We are going to be implementing the functionality and it'd be nice to prep for that too.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/Automattic/vip-real-time-collaboration/compare/add/view-only-mode?expand=1

Got a version of this for the view only mode that I'm working on. It's a toggle for just the view only mode but ideally it should be a "enable elected modes" which in turn reveals that modal.


return (
<>
<CollaborationMode>
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be feature flagged btw. It's not in use right now as we are still developing it.

Copy link
Contributor

@ingeniumed ingeniumed left a comment

Choose a reason for hiding this comment

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

Should really use another slotfill that we have added to Gutenberg? I think there's some merit to the feedback that was mentioned in the Gutenberg PR. I know the designs suggest putting it in that location, but I wonder if it's better to instead have it in one of two places:

  • Next to the publish/save button if it's really needed in the top document bar. There's some work in the workflow plugin that'd be useful to check out here on how to do this.

  • Within the post info, where the details of the post are present. We could add a mode dropdown there so you could select what mode you are in.

I honestly like #2 more, as we would take advantage of the Post info and it relates to how the "post" is being worked on imo.

Image

Prob need some feedback from @jarekmorawski.

Hide the collaboration mode picker behind a development-only setting
since the functionality is not yet complete.
Wrapped all UI strings in the collaboration mode picker and settings
panel with the __() function to support translations.
@shekharnwagh
Copy link
Contributor Author

I was thinking if toggling off the mode selection should reset the mode to the default value - edit, but maybe that would be confusing to the user as why was I moved to edit mode from view mode. This toggle to hide/show this feature might be temporary until we finish it, so my though is to not add additional logic for this.

@ingeniumed
Copy link
Contributor

I was thinking if toggling off the mode selection should reset the mode to the default value - edit, but maybe that would be confusing to the user as why was I moved to edit mode from view mode. This toggle to hide/show this feature might be temporary until we finish it, so my though is to not add additional logic for this.

Yip, the toggle is temporary during the development of the elected modes feature. Once we finish development, we'll remove the toggle and allow the model to always be visible with a default value set to Edit. Then, as part of enforced modes we can tweak what the default model values should be.

case 'SET_MODE': {
return {
...state,
currentMode: action.payload.mode,
Copy link
Contributor

Choose a reason for hiding this comment

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

Noting this for a follow up PR: We should save this mode into local storage like the settings are saved right now and read from there as well. That way on refresh it's not lost.

Copy link
Contributor Author

@shekharnwagh shekharnwagh Nov 14, 2025

Choose a reason for hiding this comment

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

I didn't persist this in localStorage intentionally as that would lead to that getting persisted for other posts even those open in other tabs. Using sessionStorage might be better as thats limited to the current tab, would still apply to another post opened in same tab. If we do want to persist on refresh, might to strike a balance here. Top of mind we could persist something like Record< postId, mode > in sessionStorage and check by postId.

Copy link
Contributor

Choose a reason for hiding this comment

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

I figured, whether we use local or session storage the key would be used to differentiate that.

One other important part is that, we would want to eventually persist these on user meta possible so a user can carry this from one browser session to the other.

@ingeniumed ingeniumed merged commit 452e493 into trunk Nov 14, 2025
15 checks passed
@ingeniumed ingeniumed deleted the add/collaboration-mode-picker branch November 14, 2025 02:15
@ingeniumed
Copy link
Contributor

Noting that in #110, there's a bunch of cleanup I'm doing to this PR.

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.

3 participants