-
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
Changes from all commits
de6d148
d6869ad
5653cdf
07ace6b
ed2bfb1
7720db9
2489a85
bb11ae6
29a6db7
b3488aa
33f6fb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
} from 'AppV2/Utils/trade-params-utils'; | ||
import { useDtraderQuery } from 'AppV2/Hooks/useDtraderQuery'; | ||
import { ProposalResponse } from 'Stores/Modules/Trading/trade-store'; | ||
import { removeFocus } from 'AppV2/Utils/layout-utils'; | ||
|
||
const timeToMinutes = (time: string) => { | ||
const [hours, minutes] = time.split(':').map(Number); | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Based on comments I did another solution, could you please check? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
setOpen(true); | ||
}} | ||
leftIcon={<LabelPairedCalendarSmRegularIcon width={24} height={24} />} | ||
|
@@ -164,7 +166,8 @@ const DayInput = ({ | |
name='time' | ||
value={`${(formatted_date === formatted_current_date ? end_time : temp_expiry_time) || '23:59:59'} GMT`} | ||
disabled={formatted_date !== formatted_current_date || !is_24_hours_contract} | ||
onClick={() => { | ||
onClick={(e: React.MouseEvent<HTMLInputElement, MouseEvent>) => { | ||
removeFocus(e); | ||
setOpenTimePicker(true); | ||
}} | ||
leftIcon={<LabelPairedClockThreeSmRegularIcon width={24} height={24} />} | ||
|
@@ -184,6 +187,7 @@ const DayInput = ({ | |
onClose={() => { | ||
setOpen(false); | ||
setOpenTimePicker(false); | ||
removeFocus(); | ||
}} | ||
position='left' | ||
expandable={false} | ||
|
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)