Skip to content

Commit

Permalink
Meenu market scroll section (#679)
Browse files Browse the repository at this point in the history
* fix: updated dropdown size and added default value

* empty: empty commit

* fix: fixed sorting issue

* fix: fixed scroll upward issue

* fix: fixed scroll to selected element

* fix: updated classname

* fix: removed upward scroll fixes
  • Loading branch information
meenakshi-deriv authored Jul 18, 2024
1 parent 8233c67 commit f2e85ba
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/javascript/app/pages/trade/markets/markets-dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ export const MarketsDropdown = () => {
closeMarketDropdown();
};

useEffect(() => {
if (isMounted && itemsContainer.current) {

const container = itemsContainer.current;
const selectedElement = container.querySelector('.market-item-selected');
if (selectedElement) {
const offsetTop = selectedElement.offsetTop - container.offsetTop;
container.scrollTo({
top : offsetTop,
behavior: 'auto',
});
}

}
}, [isMounted]);

return (
<div className='quill-market-dropdown-container'>
<div className='quill-market-dropdown-search-container'>
Expand Down Expand Up @@ -244,7 +260,7 @@ export const MarketsDropdown = () => {
{Object.keys(markets).map((ik) => {
const market = markets[ik];
const { submarkets } = market;

const sortedSubmarketKeys = Object.keys(submarkets).sort((a, b) => {
if (a === 'major_pairs') return -1;
if (b === 'major_pairs') return 1;
Expand Down Expand Up @@ -273,6 +289,7 @@ export const MarketsDropdown = () => {
onClick={() => handleUnderlyingClick(yk)}
label={display}
selected={isSelected}
className={isSelected && 'market-item-selected'}
size='md'
/>
);
Expand Down

0 comments on commit f2e85ba

Please sign in to comment.