statelyai / studio-issues

Report issues found in Stately Studio
5 stars 0 forks source link

Support multiple targets in the editor #59

Open SimeonC opened 2 years ago

SimeonC commented 2 years ago

Editing a machine using the VSCode editor with the following state node config will end up with a broken machine as the in specifier and the multiple targets get stripped out.

setup: {
  invoke: {
    src: 'loadSearchSources',
      onDone: [
        {
          actions: ['cacheSearchElements', 'setInitialResults'],
          cond: 'hasSearch',
          in: '#Sub Menu Machine.menu.rest',
          target: [
            '#Sub Menu Machine.search.searching',
            '#Sub Menu Machine.menu.rest.entry'
          ]
        },
        {
          actions: ['cacheSearchElements', 'setInitialResults'],
          cond: 'hasSearch',
          target: '#Sub Menu Machine.search.searching'
        },
        {
          actions: ['cacheSearchElements', 'setInitialResults'],
          in: '#Sub Menu Machine.menu.rest',
          target: [
            '#Sub Menu Machine.search.searching',
            '#Sub Menu Machine.menu.rest.entry'
          ]
        },
        {
          actions: ['cacheSearchElements', 'setInitialResults'],
          target: '#Sub Menu Machine.search.rest'
        }
      ]
    },
    tags: 'loading',
    on: {
      SEARCH: {
        actions: 'setSearchText',
        internal: true,
        target: '#Sub Menu Machine.search.setup'
      }
    }
  },
mattpocock commented 2 years ago

Currently, the editor does not support multiple targets per transition. This is something we need to figure out to bring the editor up to XState feature parity.

mattpocock commented 2 years ago

We can support in, though - will add that as a separate issue.

davidkpiano commented 2 years ago

Added to Linear, this is something we want to support: https://linear.app/statelyai/issue/STA-1290/support-for-multiple-targets

aceslick911 commented 2 years ago

Just bumping this with a +1 if that’s allowed 😅

schickling commented 2 years ago

Some more feedback from someone who's new to xstate and learns the overall technology by writing the code and using the visual editor side-by-side:

Having the multiple target values not be reflected in the editor UI led me to the (wrong) conclusion that having multiple target values wasn't allowed i.e. a xstate design decision. Based on this conclusion I started completely refactoring my state machine. 🤦

ericclemmons commented 2 years ago

I just ran into this issue as well, where my machine had target: [...] like OPs but the visualizer rewrote it in VS Code to a single target: '...'.