xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

Visual editor nodes lose focus

Open mattbieber-lark opened this issue 2 years ago • 9 comments

Just noticed this today, but then I'm a bit new to the visual editor. Selecting a node (Event, State) in the editor will focus it for a split second and then lose focus as if you had clicked out of the object. I saw this mentioned by others in Discord so am logging an issue. It seems to have some correlation to the side panes having been opened. Note: I ruled out an extension conflict by disabling all but the Stately one.

Macbook Pro w/ M1 chip

2022-06-19 15 41 32 .

mattbieber-lark avatar Jun 19 '22 22:06 mattbieber-lark

no one?

mattbieber-lark avatar Jun 21 '22 06:06 mattbieber-lark

This is only happening in the VS Code extension, correct?

davidkpiano avatar Jun 21 '22 10:06 davidkpiano

Correct @davidkpiano. If it's not something affecting a bunch of people it's probably on my end. I'll debug and post my findings here for others.

mattbieber-lark avatar Jun 21 '22 17:06 mattbieber-lark

I'm surprised no one else is talking about this issue. Not only does it lose focus when clicking nodes, but also when editing the machine. I think its every time it wants to save the machine in the .ts file, it loses focus.

It's very annoying, the vscode editor is barely usable.

bcdrme avatar Sep 05 '22 08:09 bcdrme

Not only does it lose focus when clicking nodes,

Could you try to record a short video that would showcase the problem? Or at least describe the whole scenario in detail? I would be interested in knowing where you click and what you expect to be focused and when.

but also also when editing the machine.

Where do you edit it? Do you refer to the fact that touching the code of the machine might "unselect" the node in the Studio?

I think its every time it wants to save the machine in the .ts file, it loses focus.

I can definitely see this happening, since I'm reworking the relevant parts of the code I will try to fix this while doing so.

Andarist avatar Sep 05 '22 08:09 Andarist

Here I'm trying to type "Trying to name this state". As you can see, it loses focus.

Focus is lost

I'm pretty sure the issue is : debounce on the input kicks off -> it triggers "generate the machine code" -> machine code is saved to the .ts file -> TS file has changed, reload the Studio.

In 1.9.0, a feature has been added : #188 e54ce0d Thanks @mellson! - Changes made outside VS Code are now sent to the visual editor.

So, maybe its related ?

bcdrme avatar Sep 05 '22 09:09 bcdrme

@bcdrme That's very likely the issue. The most probable fix is to avoid sending changes to VS Code until you've "committed" the change (e.g. by blurring the input).

davidkpiano avatar Sep 05 '22 13:09 davidkpiano

Tracking in Linear: https://linear.app/statelyai/issue/STA-2201

davidkpiano avatar Sep 05 '22 13:09 davidkpiano

Disabling the autosave feature from vscode is a workaround

image

bcdrme avatar Sep 05 '22 16:09 bcdrme

I believe that I've fixed the issue in one of our dependencies that was causing this: https://github.com/chakra-ui/chakra-ui/pull/6863

Andarist avatar Nov 08 '22 16:11 Andarist