Skip to content

Commit

Permalink
FIXED: get cache under mouse right clicking on tab icon, fixes #96
Browse files Browse the repository at this point in the history
  • Loading branch information
warpdesign committed Feb 8, 2020
1 parent a34121e commit a5addb0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,15 @@ class TabListClass extends React.Component<InjectedProps> {
}
};

onFolderContextMenu = (e: React.MouseEvent) => {
onFolderContextMenu = (index:number, e: React.MouseEvent) => {
const { t } = this.injected;
const { viewState } = this.injected;

e.preventDefault();
e.stopPropagation();

// TODO: get path entries
const cache = viewState.getVisibleCache();
const tree = cache.getAPI().getParentTree(cache.path);
const cacheUnderMouse = viewState.caches[index];
const tree = cacheUnderMouse.getAPI().getParentTree(cacheUnderMouse.path);

const template: MenuItemConstructorOptions[] = tree.map((el: { dir: string, fullname: string, name: string }) => {
return {
Expand Down Expand Up @@ -223,7 +222,7 @@ class TabListClass extends React.Component<InjectedProps> {
const tabInfo = cache.getFS() && cache.getFS().displaypath(path) || { fullPath: '', shortPath: '' };

return (
<Button key={"" + viewId + index} onContextMenu={() => this.onContextMenu(index)} onClick={this.selectTab.bind(this, index)} title={tabInfo.fullPath} intent={cache.isVisible ? "primary" : "none"} rightIcon={closeIcon} className="tab"><Icon onContextMenu={this.onFolderContextMenu} className="folder" icon={tabIcon}></Icon>{tabInfo.shortPath}</Button>
<Button key={"" + viewId + index} onContextMenu={() => this.onContextMenu(index)} onClick={this.selectTab.bind(this, index)} title={tabInfo.fullPath} intent={cache.isVisible ? "primary" : "none"} rightIcon={closeIcon} className="tab"><Icon onContextMenu={this.onFolderContextMenu.bind(this, index)} className="folder" icon={tabIcon}></Icon>{tabInfo.shortPath}</Button>
)
})
}
Expand Down

0 comments on commit a5addb0

Please sign in to comment.