mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix pr comments. Cleanup function. Simplify reaction
Signed-off-by: DmitriyNoa <dmytro.zharkov@gmail.com>
This commit is contained in:
parent
1d79392668
commit
0a4510d253
@ -233,15 +233,6 @@ export class DockStore implements DockStorageState {
|
|||||||
}), reactionOpts);
|
}), reactionOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
onTabsNumberChange(callback: (evt: DockTabsNumberEvent) => void) {
|
|
||||||
return reaction(() => this.tabsNumber, ((currentTabsNumber, previousTabsNumber) => {
|
|
||||||
callback({
|
|
||||||
currentTabsNumber,
|
|
||||||
previousTabsNumber,
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
hasTabs() {
|
hasTabs() {
|
||||||
return this.tabs.length > 0;
|
return this.tabs.length > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { Fragment, useRef, useEffect, useState, UIEvent } from "react";
|
import React, { Fragment, useRef, useEffect, useState, UIEvent } from "react";
|
||||||
|
import { reaction } from "mobx";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { Tabs } from "../tabs/tabs";
|
import { Tabs } from "../tabs/tabs";
|
||||||
import { DockTab } from "./dock-tab";
|
import { DockTab } from "./dock-tab";
|
||||||
@ -109,9 +110,12 @@ export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab, dockStore
|
|||||||
window.addEventListener("resize", onWindowResize);
|
window.addEventListener("resize", onWindowResize);
|
||||||
|
|
||||||
// update scroll state if tabs numbers has changed
|
// update scroll state if tabs numbers has changed
|
||||||
dockStore.onTabsNumberChange(() => {
|
reaction(() => dockStore.tabsNumber, updateStateValues);
|
||||||
updateStateValues();
|
|
||||||
});
|
return () => {
|
||||||
|
window.removeEventListener("resize", onWindowResize);
|
||||||
|
elem.current.removeEventListener("scroll", updateScrollPosition);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user