Skip to content
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

Conversation

kate-deriv
Copy link
Contributor

@kate-deriv kate-deriv commented Oct 14, 2024

Changes:

  • Fixed scrolling issue: because trade params components were built around the input field, they got focus on click and that caused scrolling issue. Only in cases, when inside of ActionSheet (which opens on trade param click) there was Wheel Picker, which caught focus, scrolling was working as expected. ===> Created a function, which removes focus.
  • Added test.

Screenshots:

Screenshot 2024-10-14 at 11 05 07 AM

Screen.Recording.2024-10-14.at.10.56.28.AM.mov

Copy link

vercel bot commented Oct 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
deriv-app ✅ Ready (Inspect) Visit Preview Oct 16, 2024 9:42am

Copy link
Contributor

github-actions bot commented Oct 14, 2024

A production App ID was automatically generated for this PR. (log)

Click here to copy & paste above information.
- **PR**: [https://github.com/deriv-com/deriv-app/pull/17176](https://github.com/deriv-com/deriv-app/pull/17176)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-kate-deriv-kate-dtra-2055tradingpages-8f09df.binary.sx?qa_server=red.derivws.com&app_id=23881
    - **Original**: https://deriv-app-git-fork-kate-deriv-kate-dtra-2055tradingpages-8f09df.binary.sx
- **App ID**: `23881`

Copy link
Contributor

github-actions bot commented Oct 14, 2024

🚨 Lighthouse report for the changes in this PR:

Category Score
🔺 Performance 31
🟧 Accessibility 70
🟢 Best practices 92
🟧 SEO 77
🟧 PWA 78

Lighthouse ran with https://deriv-app-git-fork-kate-deriv-kate-dtra-2055tradingpages-8f09df.binary.sx/

@coveralls
Copy link

coveralls commented Oct 14, 2024

Pull Request Test Coverage Report for Build 11363444679

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 43 of 45 (95.56%) changed or added relevant lines in 12 files are covered.
  • 1076 unchanged lines in 32 files lost coverage.
  • Overall coverage increased (+0.02%) to 53.625%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/trader/src/AppV2/Components/TradeParameters/RiskManagement/risk-management.tsx 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
packages/wallets/src/components/DerivAppsSection/DerivAppsGetAccount.tsx 1 80.6%
packages/account/src/Sections/Profile/PersonalDetails/verify-button.tsx 1 95.38%
packages/core/src/Utils/Analytics/index.ts 1 0.0%
packages/cashier/src/modules/cashier-onboarding/components/cashier-onboarding-side-notes/cashier-onboarding-side-note-fiat.tsx 1 71.43%
packages/wallets/src/features/accounts/modules/ManualService/components/DrivingLicenseUpload/DrivingLicenseUpload.tsx 1 0.0%
packages/cashier/src/components/cashier-locked/cashier-locked-provider.tsx 1 84.34%
packages/wallets/src/features/accounts/modules/ManualService/components/PassportUpload/PassportUpload.tsx 1 0.0%
packages/wallets/src/features/cashier/modules/WithdrawalCrypto/provider/WithdrawalCryptoProvider.tsx 1 51.37%
packages/wallets/src/features/accounts/modules/ManualService/components/IdentityCardUpload/IdentityCardUpload.tsx 1 0.0%
packages/cashier/src/pages/account-transfer/account-transfer.tsx 1 98.18%
Totals Coverage Status
Change from base Build 11322810823: 0.02%
Covered Lines: 34756
Relevant Lines: 60300

💛 - Coveralls

@kate-deriv kate-deriv marked this pull request as ready for review October 14, 2024 11:29
@kate-deriv kate-deriv changed the title DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue [WIP] Oct 14, 2024
@kate-deriv kate-deriv changed the title DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue [WIP] DTRA-2055 / Kate / [DTrader-V2] Trade page scrolling issue Oct 16, 2024
Copy link
Contributor

github-actions bot commented Oct 16, 2024

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);
Copy link
Contributor

@wojciech-deriv wojciech-deriv Oct 16, 2024

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.

cc @kate-deriv @nijil-deriv

Copy link
Contributor Author

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

Copy link
Contributor Author

@kate-deriv kate-deriv Oct 16, 2024

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

Copy link
Contributor Author

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();
Copy link
Contributor

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)

@kate-deriv kate-deriv closed this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants