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

Avoid closing IDE accidentally #390

Merged

Conversation

kewinzaq1
Copy link
Collaborator

@kewinzaq1 kewinzaq1 commented Jun 17, 2024

Problem

Currently, there is a chance of accidentally closing the IDE panel and it can be an unpleasant experience

Solution

Simple confirmation popup to avoid headaches. The following popup only appears if users click cmd+w/ctr+w
https://github.com/software-mansion/react-native-ide/assets/77052270/70c45f35-9d89-4b99-ad97-9f69e0cbc96e

#387

Copy link

vercel bot commented Jun 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2024 4:31pm

@kewinzaq1 kewinzaq1 force-pushed the avoid-closing-ide-accidentally branch from 45668d9 to e8fca52 Compare June 17, 2024 18:27
@kewinzaq1 kewinzaq1 changed the title (WIP) Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Jun 17, 2024
@kewinzaq1 kewinzaq1 changed the title Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) (WIP) Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Jun 17, 2024
@kewinzaq1 kewinzaq1 force-pushed the avoid-closing-ide-accidentally branch from e8fca52 to e4f9a0f Compare June 19, 2024 15:59
@kewinzaq1 kewinzaq1 force-pushed the avoid-closing-ide-accidentally branch from e4f9a0f to ee75bcf Compare June 19, 2024 15:59
@kewinzaq1 kewinzaq1 changed the title (WIP) Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Jun 22, 2024
@kmagiera kmagiera changed the title Avoid closing IDE accidentally (https://github.com/software-mansion/react-native-ide/issues/387) Avoid closing IDE accidentally Jun 25, 2024
Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

Thanks for this. I like the idea but would suggest the following changes:

  1. use onDidChangeActiveTextEditor instread of the tab group change event
  2. register the event in Tabpanel instead of extension.ts and make sure we call dispose on the result of registration when dispose is triggered on the panel
  3. Use panel.active field to tell whether the IDE panel is focused (https://code.visualstudio.com/api/references/vscode-api#WebviewPanel)
  4. Rename isTabActive to isTabPanelFocused since word "active" is ambiguous in this context
  5. Rename "doubleClickClose" to "closeWithConfirmation"

@kewinzaq1
Copy link
Collaborator Author

@kmagiera Thanks for the review.
I tried to go with onDidChangeActiveTextEditor however I ended up checking the active state 
this._panel.active before the update had happened, so I moved to the direct method on the panel; onDidChangeViewState allows for avoiding this problem pretty straightforwardly. What do you think about this approach?

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

This is much better. I'm ok with using onDidChangeViewState if it works and gets triggered at the right moment. Only added one more comment inline and this should be good to go.

packages/vscode-extension/src/panels/Tabpanel.ts Outdated Show resolved Hide resolved
Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

This is great. Thanks for working on the requested changes!

@kmagiera kmagiera merged commit 81f9cb0 into software-mansion:main Jun 26, 2024
3 checks passed
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.

2 participants