-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue #17176
DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue #17176
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-kate-deriv-kate-dtra-2055tradingpages-8f09df.binary.sx/ |
packages/trader/src/AppV2/Components/TradeParameters/Barrier/barrier.tsx
Outdated
Show resolved
Hide resolved
⏳ Generating Lighthouse report... |
@@ -151,7 +152,8 @@ const DayInput = ({ | |||
textAlignment='center' | |||
value={formatted_date} | |||
disabled={duration_units_list.filter(item => item.value === 'd').length === 0} | |||
onClick={() => { | |||
onClick={(e: React.MouseEvent<HTMLInputElement, MouseEvent>) => { | |||
removeFocus(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any chance to find solution which does not require to remember to remove focus from every single element? it feels like a recipe for sneaky bugs, I'm sure ppl will forget and it will sneak through the PRs.
The same way missing dependencies in useHook sneaks through all the time and causes sneaky bugs all the time. Everyone knows about useEffect dependencies, but ppl still forget to add them and miss them in reviews, so basically its a source of bugs and unnecessary overhead in reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to rework, @nijil-deriv gave me a tip to think about wrapper. The idea is to wrap all trade params with wrapper and inside that wrapper to track focus. If it'll be inside input, then remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on comments I did another solution, could you please check?
Link
What was done: TradeParameters
(in packages/trader/src/AppV2/Components/TradeParameters/trade-parameters.tsx) is a container for all trade parameters, so inside of useEffect
I added an event listener for focusin
. If event.target
contains specific custom attribute (data-focus
), then I'll remove focus.
Custom attributes (data-focus
) were added for all trade params inputs. That was the only way that works for me to indicate that it's correct input. We can't just remove focus from all inputs inside trade params components as user won't be able to even type something for stake, barrier and etc
@wojciech-deriv @nijil-deriv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If alternative solution will melt your hearts, I'll merge that branch into a current one
isOpen={is_open} | ||
onClose={() => { | ||
onClose(false); | ||
removeFocus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to remove focus on ActionSheet close and on every single element?
wouldn't it be sufficient to only remove focus from action sheet, or just generic document.body.blur()
?
or maybe, the option would be to specifically focus on some choosen element - e.g. do tricks like window.focus()?
(or combination of document.body.blur(); and then window.focus() - I have not tested details, just trying to figure out something which could help us avoid to remember the removeFocus in every component with focus)
Changes:
Screenshots:
Screen.Recording.2024-10-14.at.10.56.28.AM.mov