Skip to content

Commit

Permalink
fix: changes due to comments in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardIvanov22 committed Dec 6, 2021
1 parent ff9e257 commit 4247b98
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/organisms/ActionsPane/ActionsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,30 @@ const ActionsPane = (props: {contentHeight: string}) => {
const isActionsPaneFooterExpanded = useAppSelector(state => state.ui.isActionsPaneFooterExpanded);
const kubeconfigPath = useAppSelector(state => state.config.kubeconfigPath);
const [key, setKey] = useState('source');
const [isButtonShrinked, setButtonCollapsedState] = useState<boolean>();
const [isButtonShrinked, setButtonShrinkedState] = useState<boolean>();

const dispatch = useAppDispatch();

// Could not get the ref of Tabs Component
const tabsList = document.getElementsByClassName('ant-tabs-nav-list')[0];
const tabsList = document.getElementsByClassName('ant-tabs-nav-list');
const extraButton = useRef<any>();

const getDistanceBetweenComponents = () => {
const tabsListEl = document.getElementsByClassName('ant-tabs-nav-list')[0].getBoundingClientRect();
const getDistanceBetweenTwoComponents = () => {
const tabsListEl = tabsList[0].getBoundingClientRect();
const extraButtonEl = extraButton.current.getBoundingClientRect();

const distance = extraButtonEl.left - tabsListEl.right;

if (isButtonShrinked) {
// 230px = approx width of not collapsed button
if (distance > 230) {
setButtonCollapsedState(false);
setButtonShrinkedState(false);
}
}

// The button has 10px margin-left
if (!isButtonShrinked && distance < 10) {
setButtonCollapsedState(true);
setButtonShrinkedState(true);
}
};

Expand Down Expand Up @@ -328,8 +328,8 @@ const ActionsPane = (props: {contentHeight: string}) => {
}, [selectedResource]);

useEffect(() => {
if (tabsList && extraButton.current) {
getDistanceBetweenComponents();
if (tabsList && tabsList.length && extraButton.current) {
getDistanceBetweenTwoComponents();
}
}, [tabsList, extraButton.current, uiState.paneConfiguration, windowSize]);

Expand Down

0 comments on commit 4247b98

Please sign in to comment.