-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: add context menu to file tabs with close actions #162
base: staging
Are you sure you want to change the base?
Conversation
|
||
interface IContextMenuItems extends MenuProps { | ||
key: ContextMenuKeys; | ||
items: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested objects should almost always be defined as a separate type alias. Necessity of IContextMenuItems['items']
supports this.
@@ -22,6 +53,9 @@ const Tabs: FC = () => { | |||
close(filePath); | |||
}; | |||
|
|||
const onMenuItemClick = (info: MenuInfo, filePath: Tree['path']) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will force the rerender of the whole tab list every time Tabs
component gets an update. Event handlers should be enclosed in useCallback
.
src/hooks/fileTabs.hooks.ts
Outdated
const updatedItems = fileTab.items.filter( | ||
(item) => item.path === filePath, | ||
); | ||
updatedTab = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutable updatedTab
unnecessarily increases code complexity.
It'd be much easier to return
instead, and factor out syncTabSettings
out of this function.
Also syncTabSettings
gets exported along with open
and close
, even though it's semantically/architecturally a deeper concept. Probably it's worth it to check if there is a way to avoid returning syncTabSettings
from this function, and incapsulate all the logic related to tab syncing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed syncTabSettings from this hook and made the required changes as suggested by you.
This is open for 3 weeks without progress. Should we close it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rahulyadav-57 please resolve the comments
I was working on Misti support, so it was delayed. I'll resolve it soon. |
Resolves #72