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

feat: add context menu to file tabs with close actions #162

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

rahulyadav-57
Copy link
Member

Resolves #72


interface IContextMenuItems extends MenuProps {
key: ContextMenuKeys;
items: {
Copy link
Collaborator

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']) => {
Copy link
Collaborator

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.

const updatedItems = fileTab.items.filter(
(item) => item.path === filePath,
);
updatedTab = {
Copy link
Collaborator

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.

Copy link
Member Author

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.

@verytactical
Copy link
Collaborator

This is open for 3 weeks without progress. Should we close it?

Copy link
Member

@anton-trunov anton-trunov left a 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

@rahulyadav-57
Copy link
Member Author

I was working on Misti support, so it was delayed. I'll resolve it soon.

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.

3 participants