From d27e16293cb949275c2d5255726aa52a185d7dcc Mon Sep 17 00:00:00 2001 From: maryia-deriv Date: Thu, 8 Aug 2024 15:53:13 +0300 Subject: [PATCH] refactor: 1 more timer cleanup and more nit-picks --- scripts/common.js | 2 +- src/javascript/app/pages/bottom/tabs.jsx | 6 ++---- .../app/pages/trade/markets/contracts-dropdown.jsx | 6 ++++-- src/sass/_common/components.scss | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/common.js b/scripts/common.js index 7e2700acb55..273f77b9ae9 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -21,7 +21,7 @@ exports.sections_config = { '': { // '' is the default section when no 'section' specified in pages.js (to avoid adding 'app' as section for all) path : '', js_files : ['vendor', 'binary'], - css_files: ['common.min', 'app.min', 'static.min','reset.min'], + css_files: ['common.min', 'app.min', 'static.min', 'reset.min'], has_pjax : true, }, }; diff --git a/src/javascript/app/pages/bottom/tabs.jsx b/src/javascript/app/pages/bottom/tabs.jsx index a541f99c644..325fc573d1b 100644 --- a/src/javascript/app/pages/bottom/tabs.jsx +++ b/src/javascript/app/pages/bottom/tabs.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import ReactDOM from 'react-dom'; import { SegmentedControlSingleChoice } from '@deriv-com/quill-ui'; import { Explanation } from './explanation.jsx'; @@ -75,9 +75,7 @@ const BottomTabs = () => { }, 100); }, [selectedTab, savedTab]); - useEffect(() => { - return () => clearTimeout(triggerOldTabTimer.current); - }, []); + useEffect(() => () => clearTimeout(triggerOldTabTimer.current), []); return ( <> diff --git a/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx b/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx index 4791e07f1c8..7f74806bae6 100644 --- a/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx +++ b/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx @@ -10,6 +10,7 @@ export const ContractDropdown = () => { const [data, setData] = useState(dataManager.getAllContracts()); const selectedRef = useRef(null); const containerRef = useRef(null); + const closeDropdownTimer = useRef(); const onContractClick = (formName) => { if (formName === data?.formName) { return; } @@ -30,12 +31,13 @@ export const ContractDropdown = () => { triggerContractChange(); - setTimeout(() => { + closeDropdownTimer.current = setTimeout(() => { close(); }, 10); - }; + useEffect(() => () => clearTimeout(closeDropdownTimer.current), []); + useEffect(() => { setData(oldData => ({ ...oldData, diff --git a/src/sass/_common/components.scss b/src/sass/_common/components.scss index 60effcd4041..490905ca906 100644 --- a/src/sass/_common/components.scss +++ b/src/sass/_common/components.scss @@ -28,7 +28,7 @@ } } -.highcharts-container { +.highcharts-container { .highcharts-subtitle { white-space: normal !important;