Skip to content

Commit

Permalink
fix: updated scroll behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
meenakshi-deriv committed Aug 28, 2024
1 parent d7d5fc5 commit 5b5ffdd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/javascript/app/pages/trade/purchase/purchase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,21 @@ const Purchase = () => {
};

const responsivePurchaser = useRef(null);
const responsiveSize = window.innerWidth < 763;
const scrollToPurchaseContainer = () => {
const purchaseContainer = document.getElementById('purchase_container');
if (purchaseContainer) {
purchaseContainer.scrollIntoView({ block: 'center', behavior: 'smooth' });
}
};

const scrollToContractsFormContainer = () => {
const contractsFormContainer = document.getElementById('trading_socket_container');
if (contractsFormContainer) {
contractsFormContainer.scrollIntoView({ block: 'start', behavior: 'smooth' });
}
};

useEffect(() => {
const handleScroll = () => {
const purchaseSection = document.querySelector('.quill-purchase-section');
Expand Down Expand Up @@ -296,6 +304,8 @@ const Purchase = () => {
onClick={() => {
triggerClick('#close_confirmation_container');
hidePurchaseResults();
if (responsiveSize) scrollToContractsFormContainer();

}}
>
<LabelPairedXmarkMdRegularIcon />
Expand Down Expand Up @@ -359,6 +369,7 @@ const Purchase = () => {
onClick={() => {
triggerClick('#close_confirmation_container');
hidePurchaseResults();
if (responsiveSize) scrollToContractsFormContainer();
}}
>
<LabelPairedXmarkMdRegularIcon />
Expand Down

0 comments on commit 5b5ffdd

Please sign in to comment.