mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
fix(Sidebar): scroll to top once the sidebar be closed.
This commit is contained in:
@@ -16,19 +16,42 @@ function SidebarContainer({
|
||||
// #withDashboard
|
||||
sidebarExpended,
|
||||
}) {
|
||||
const sidebarScrollerRef = React.useRef();
|
||||
|
||||
useEffect(() => {
|
||||
document.body.classList.toggle('has-mini-sidebar', !sidebarExpended);
|
||||
|
||||
if (!sidebarExpended && sidebarScrollerRef.current) {
|
||||
sidebarScrollerRef.current.scrollTo({
|
||||
top: 0,
|
||||
left: 0,
|
||||
});
|
||||
}
|
||||
}, [sidebarExpended]);
|
||||
|
||||
const handleSidebarMouseLeave = () => {
|
||||
if (!sidebarExpended && sidebarScrollerRef.current) {
|
||||
sidebarScrollerRef.current.scrollTo({ top: 0, left: 0, });
|
||||
}
|
||||
};
|
||||
|
||||
const scrollerElementRef = (ref) => {
|
||||
sidebarScrollerRef.current = ref;
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames('sidebar', {
|
||||
'sidebar--mini-sidebar': !sidebarExpended,
|
||||
})}
|
||||
id="sidebar"
|
||||
onMouseLeave={handleSidebarMouseLeave}
|
||||
>
|
||||
<div className={'sidebar__scroll-wrapper'}>
|
||||
<Scrollbar noDefaultStyles={true}>
|
||||
<Scrollbar
|
||||
noDefaultStyles={true}
|
||||
scrollerProps={{ elementRef: scrollerElementRef }}
|
||||
>
|
||||
<div className="sidebar__inner">{children}</div>
|
||||
</Scrollbar>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, { useState, createContext } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import {
|
||||
useCustomers,
|
||||
useCustomer,
|
||||
useCurrencies,
|
||||
useCreateCustomer,
|
||||
@@ -18,22 +17,17 @@ function CustomerFormProvider({ customerId, ...props }) {
|
||||
const contactId = state?.action;
|
||||
|
||||
// Handle fetch customer details.
|
||||
const { data: customer, isFetching: isCustomerLoading } = useCustomer(
|
||||
const { data: customer, isLoading: isCustomerLoading } = useCustomer(
|
||||
customerId,
|
||||
{
|
||||
enabled: !!customerId,
|
||||
},
|
||||
{ enabled: !!customerId },
|
||||
);
|
||||
|
||||
// Handle fetch contact duplicate details.
|
||||
const { data: contactDuplicate, isFetching: isContactLoading } = useContact(
|
||||
const { data: contactDuplicate, isLoading: isContactLoading } = useContact(
|
||||
contactId,
|
||||
{
|
||||
enabled: !!contactId,
|
||||
},
|
||||
{ enabled: !!contactId, },
|
||||
);
|
||||
// Handle fetch Currencies data table
|
||||
const { data: currencies, isFetching: isCurrenciesLoading } = useCurrencies();
|
||||
const { data: currencies, isLoading: isCurrenciesLoading } = useCurrencies();
|
||||
|
||||
// Form submit payload.
|
||||
const [submitPayload, setSubmitPayload] = useState({});
|
||||
|
||||
@@ -29,7 +29,7 @@ function InvoiceFormProvider({ invoiceId, ...props }) {
|
||||
// Fetches the estimate by the given id.
|
||||
const {
|
||||
data: estimate,
|
||||
isFetching: isEstimateFetching,
|
||||
isLoading: isEstimateLoading,
|
||||
} = useEstimate(estimateId, { enabled: !!estimateId });
|
||||
|
||||
const newInvoice = !isEmpty(estimate)
|
||||
@@ -97,7 +97,7 @@ function InvoiceFormProvider({ invoiceId, ...props }) {
|
||||
isInvoiceLoading ||
|
||||
isItemsLoading ||
|
||||
isCustomersLoading ||
|
||||
isEstimateFetching ||
|
||||
isEstimateLoading ||
|
||||
isSettingsLoading
|
||||
}
|
||||
name={'invoice-form'}
|
||||
|
||||
@@ -20,21 +20,19 @@ function VendorFormProvider({ vendorId, ...props }) {
|
||||
const { state } = useLocation();
|
||||
|
||||
// Handle fetch Currencies data table
|
||||
const { data: currencies, isFetching: isCurrenciesLoading } = useCurrencies();
|
||||
const { data: currencies, isLoading: isCurrenciesLoading } = useCurrencies();
|
||||
|
||||
// Handle fetch vendor details.
|
||||
const { data: vendor, isFetching: isVendorLoading } = useVendor(vendorId, {
|
||||
const { data: vendor, isLoading: isVendorLoading } = useVendor(vendorId, {
|
||||
enabled: !!vendorId,
|
||||
});
|
||||
|
||||
const contactId = state?.action;
|
||||
|
||||
// Handle fetch contact duplicate details.
|
||||
const { data: contactDuplicate, isFetching: isContactLoading } = useContact(
|
||||
const { data: contactDuplicate, isLoading: isContactLoading } = useContact(
|
||||
contactId,
|
||||
{
|
||||
enabled: !!contactId,
|
||||
},
|
||||
{ enabled: !!contactId },
|
||||
);
|
||||
|
||||
// Create and edit vendor mutations.
|
||||
|
||||
@@ -237,6 +237,10 @@
|
||||
transition: min-width 0.15s ease-in-out;
|
||||
min-width: 50px;
|
||||
|
||||
.ScrollbarsCustom-Scroller{
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
min-width: 220px;
|
||||
|
||||
@@ -251,6 +255,10 @@
|
||||
.sidebar__menu {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ScrollbarsCustom-Scroller{
|
||||
overflow: scroll !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user