Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit e80f1d5

Browse files
Aizad/Fix Derived toggle click on reload (#7293)
* task: fix derived toggle click on reload * fix: active icon behavior * resolved: replace with classNames function --------- Co-authored-by: Matin shafiei <[email protected]>
1 parent 8b9d036 commit e80f1d5

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

src/javascript/app/pages/trade/markets.jsx

+40-13
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ class Markets extends React.Component {
191191
};
192192

193193
toggleAccordion = () => {
194-
this.setState({ open_accordion: !this.state.open_accordion });
194+
this.setState((prevState) => ({
195+
...prevState,
196+
open_accordion: !prevState.open_accordion,
197+
}));
195198
}
196199

197200
getCurrentUnderlying = () => {
@@ -228,7 +231,6 @@ class Markets extends React.Component {
228231
} else {
229232
this.setState({
230233
subgroup_active: false,
231-
open_accordion : false,
232234
});
233235
}
234236
}
@@ -523,11 +525,16 @@ class Markets extends React.Component {
523525
<div>
524526
{group_markets[item].markets.map((m) => (
525527
<div
526-
className={`market ${active_market === m.key ? 'active' : ''}`}
528+
className={classNames('market', {
529+
'active': active_market === m.key,
530+
})}
527531
key={m.key}
528532
onClick={scrollToMarket.bind(null, `${m.key}`)}
529533
>
530-
<span className={`icon ${m.key} ${active_market === m.key ? 'active' : ''}`} />
534+
<span className={classNames(`icon ${m.key}`, {
535+
'active': active_market === m.key,
536+
})}
537+
/>
531538
<span>{m.name}</span>
532539
</div>))}
533540
</div>
@@ -538,18 +545,30 @@ class Markets extends React.Component {
538545
>
539546
<div
540547
className={classNames('market', {
541-
'active': subgroup_active,
548+
'active' : subgroup_active,
549+
'accordion-label': !!open_accordion,
542550
})}
543-
onClick={toggleAccordion || (subgroup_active ? toggleAccordion : '')}
551+
onClick={toggleAccordion}
544552
>
545-
<span className={`icon synthetic_index ${open_accordion ? 'active' : ''}`} />
553+
<span className={classNames('icon synthetic_index', {
554+
'active': subgroup_active,
555+
})}
556+
/>
546557
<span>{group_markets[item].markets[0].subgroup_name}</span>
547-
<span className={`accordion-icon icon ${open_accordion ? 'active' : ''}`} />
558+
<span className={classNames('accordion-icon icon', {
559+
'active': open_accordion,
560+
})}
561+
/>
548562
</div>
549-
<div className={`${open_accordion ? 'accordion-content--active' : 'accordion-content'}`}>
563+
<div className={classNames('accordion-content', {
564+
'accordion-content--active': open_accordion,
565+
})}
566+
>
550567
{group_markets[item].markets.map((m) => (
551568
<div
552-
className={`subgroup market ${active_market === m.key ? 'subgroup-active' : ''}`}
569+
className={classNames('subgroup market', {
570+
'subgroup-active': active_market === m.key,
571+
})}
553572
key={m.key}
554573
onClick={scrollToMarket.bind(null, `${m.key}`)}
555574
>
@@ -576,9 +595,14 @@ class Markets extends React.Component {
576595
onClick = {scrollToMarket.bind(null, m.key)}
577596
key = {m.key}
578597
data-market = {m.key}
579-
className={active_market === m.key ? 'active' : ''}
598+
className={classNames('', {
599+
'active': active_market === m.key,
600+
})}
580601
>
581-
<span className={`icon ${m.key} ${active_market === m.key ? 'active' : ''}`} />
602+
<span className={classNames(`icon ${m.key}`, {
603+
'active': active_market === m.key,
604+
})}
605+
/>
582606
</li>
583607
))}
584608
</React.Fragment>
@@ -591,7 +615,10 @@ class Markets extends React.Component {
591615
'active': (active_market === derived_category || subgroup_active),
592616
})}
593617
>
594-
<span className={`icon synthetic_index ${(active_market === derived_category || subgroup_active) ? 'active' : ''}`} />
618+
<span className={classNames('icon synthetic_index', {
619+
'active': active_market === derived_category || subgroup_active,
620+
})}
621+
/>
595622
</li>
596623
)
597624
);

src/sass/app/components/market.scss

+5
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@
170170
display: flex;
171171
flex-direction: column;
172172

173+
.accordion-label {
174+
&:hover {
175+
text-decoration: none;
176+
}
177+
}
173178
.accordion-content {
174179
flex-direction: column;
175180
display: none;

0 commit comments

Comments
 (0)