focalboard icon indicating copy to clipboard operation
focalboard copied to clipboard

Bug: Switching boards takes you to the template picker.

Open asaadmahmood opened this issue 1 year ago • 5 comments

Steps to reproduce the behavior

See video attached below. https://user-images.githubusercontent.com/11034289/182689961-1a7f1403-d36f-4ab5-9cf4-ecd1987ddd61.mp4

Expected behavior

Boards should switch normally.

Edition and Platform

  • Edition: Mattermost Boards (plugin)
  • Version: 7.2
  • Browser and OS: Chrome Mac

Additional context (optional)

Add any other context about the problem here, and any notes about the severity:

  • Sev 1: Affects critical functionality without a workaround
  • Sev 2: Affects major functionality with a difficult or non-obvious workaround
  • Sev 3: Affects minor, non-critical functionality

asaadmahmood avatar Aug 03 '22 19:08 asaadmahmood

Looks like this occurs when you search for and open a board on another team while being on a different team. Workaround is to switch teams and search for the board again.

@Pinjasaur Can you help investigate? Thanks cc @sbishel

wuwinson avatar Aug 03 '22 19:08 wuwinson

Having a hard time consistently reproducing this locally. It happens when switching between boards on different teams, but only sometimes. It doesn't appear to be related to if you select the board via the mouse cursor or keyboard shortcuts. Makes me think it's somehow related to a race condition in state?

Any tips in reproducing? @wuwinson @asaadmahmood @ogi-m

Pinjasaur avatar Aug 03 '22 23:08 Pinjasaur

@Pinjasaur It looks like it has to do with you searching and opening up a board that's on another team.

For example, on https://community-dr.staging.cloud.mattermost.com/boards/

  • We have the Contributors team with the "Developer Meeting Agenda" board under the Focalboard category.
  • In the Staff team, we have the "Focalboard V1 Features" board under the Focalboard (Internal) category.
  1. Go to the Contributors team, and open the board switcher with Cmd+K / Ctrl+K
  2. Search for and select the "Focalboard V1 Features" (which belongs to the Staff team)
  3. See error - template picker is displayed instead of the board
  4. Now go to the Staff team, and open the board switcher with Cmd+K / Ctrl+K
  5. Search for and select the "Developer Meeting Agenda" (which belongs to the Contributors team)
  6. See error - template picker is displayed instead of the board.
  7. If you search for and select "Focalboard V1 Features" while on the Staff team, or search for and select "Developer Meeting Agenda" while on the Contributors team, then the boards load properly

See recording for reference:

https://user-images.githubusercontent.com/93531870/182743149-5b44a416-e0b7-40ea-b3d3-ba8ffca9d4f4.mov

wuwinson avatar Aug 04 '22 01:08 wuwinson

Community clone doesn't have Boards plugin anymore (maybe due to the 7.2 deployment/migration that just happened in the last day)—able to repro more or less consistently on community.mattermost.com.

Pinjasaur avatar Aug 04 '22 17:08 Pinjasaur

OK, narrowed it down more. On community.mattermost.com:

Browsing Focalboard Q&A board on Contributors, open switcher & search focal and select the first result which is Focalboard OKRs on Staff team. URL becomes:

  • https://community.mattermost.com/boards/team/qghzt68dq7bopgqamcnziq69ao/b1kkw5iy54pnqtjti6y84u436aa/v8w1odtuus3gbzghwquk7m4xr6c which repros the case above

Now, do the same steps & select the same board as before. URL is now (and it renders as expected):

  • https://community.mattermost.com/boards/team/qghzt68dq7bopgqamcnziq69ao/bfpp6zftgd7nazm49xk7rip559y/vpg3zaxs9kpnwjpuzx3rp3s9u8c

Notice the different board & view IDs.

Pinjasaur avatar Aug 04 '22 17:08 Pinjasaur

@harshilsharma63 took me a while but I tracked it down to the plugin: https://github.com/mattermost/focalboard/blob/683682a08677ca574e085a44484b0c8d4233c2b7/mattermost-plugin/webapp/src/index.tsx#L243

I haven't had a chance to dig into it to a better or more appropriate way to handle it. Makes sense why it's so inconsistent—it's all dependent on the redux state and my local environment state is much less complicated than community.

Let me know if you have any ideas on how to fix it. It seems relatively fragile as-is with some complex dependencies on the Mattermost store and the Focalboard store and making sure we're pub/sub-ing changes from each of them. @jespino I know you just did that change in #3602 which touched some adjacent code—maybe you have an idea?

cc @sbishel

Pinjasaur avatar Aug 09 '22 22:08 Pinjasaur

Here's the current patch we're working with.

diff --git a/mattermost-plugin/webapp/src/index.tsx b/mattermost-plugin/webapp/src/index.tsx
index 92843ffa..74d806c8 100644
--- a/mattermost-plugin/webapp/src/index.tsx
+++ b/mattermost-plugin/webapp/src/index.tsx
@@ -241,7 +241,9 @@ export default class Plugin {
             const currentTeamID = mmStore.getState().entities.teams.currentTeamId
             if (currentTeamID && currentTeamID !== prevTeamID) {
                 if (prevTeamID && window.location.pathname.startsWith(windowAny.frontendBaseURL || '')) {
-                    browserHistory.push(`/team/${currentTeamID}`)
+                    // Not already on a URL for the team
+                    if (!window.location.pathname.startsWith(`${(windowAny.frontendBaseURL || '')}/team/${currentTeamID}`))
+                        browserHistory.push(`/team/${currentTeamID}`)
                 }
                 prevTeamID = currentTeamID
                 store.dispatch(setTeam(currentTeamID))

Pinjasaur avatar Aug 11 '22 14:08 Pinjasaur