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

[$1000] [HOLD for payment 2023-07-20] [Manual Requests] Make the Datepicker component more reusable #20630

Closed
mountiny opened this issue Jun 12, 2023 · 49 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@mountiny
Copy link
Contributor

mountiny commented Jun 12, 2023

Problem

The NewDatePicker component has went trhough couple of iterations and its time to refactor it and mainly make it easier to reuse in other flows and pages of the app. Some context in this thread

Why is it important?

We are adding more flows which require a date picker component, however, the current implementation is hard to just take and plug into some other form with different routes so it just works. For example in this PR we need to make it easy to implement a date picker to a request details page

Solution

Explore how we can simplify this component so we keep the current functionality and design ideally while improving the DX.

cc @Beamanator @burczu @WoLewicki @adamgrzybowski @s77rt @luacmartins

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018d352aca1b0ce802
  • Upwork Job ID: 1683554983031660544
  • Last Price Increase: 2023-07-24
@mountiny mountiny added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 12, 2023
@mountiny mountiny self-assigned this Jun 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 12, 2023

Triggered auto assignment to @kevinksullivan (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Jun 12, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@mountiny
Copy link
Contributor Author

Asking Bartek if he wants to tackle this one tomorrow as they originally worked on this issue

@burczu
Copy link
Contributor

burczu commented Jun 14, 2023

Hi I'm Bartek from Callstack - expert contributor group - I would like to work on this issue.

@WoLewicki
Copy link
Contributor

I would gladly review the part with subscribing to navigation and the information flow in those components 😅

@melvin-bot
Copy link

melvin-bot bot commented Jun 14, 2023

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

@mountiny
Copy link
Contributor Author

Nice, I will assign you too, its important issue to get done right

@mountiny
Copy link
Contributor Author

@burczu previously, we wanted the Year page to be its own route with the psuh-to-page design which is quite complicated.

Could we potentially make this page "internal" to the datepicker route so it looks same as a new page in the stack. This might introduce issues with the navigation tho to keep the browser back and in-app Up actions consistent.

Maybe we could also disallow deeplinking to the year page which could help with some edge cases so that when you try to access the year page by using deeplink it would redirect to the date picker first.

Not sure whats the best way but lets brainstorm our options

@melvin-bot melvin-bot bot added the Overdue label Jun 16, 2023
@burczu
Copy link
Contributor

burczu commented Jun 19, 2023

not overdue

@melvin-bot melvin-bot bot removed the Overdue label Jun 19, 2023
@ArekChr
Copy link
Contributor

ArekChr commented Jun 19, 2023

In my opinion, it's a great decision to eliminate the persistence of the calendar state upon reloading. The current implementation relies on having a separate route for the list of years in the calendar because it uses navigation.
However, in most common websites that utilize a calendar picker, there is no state persistence. Removing it would make the code more reusable and much easier to maintain

@mountiny
Copy link
Contributor Author

Thanks for chiming in @ArekChr. I agree this will make the Datepicker better component from the developer perspective and there is questionable benefit from having the state persistance. Its in theory nice for users that the state is not lost but we dont really have any data or proves users would be running to this issue, they will most likely "get it".

@mountiny
Copy link
Contributor Author

Would you be able to prepare a proposal for the refactor keeping the same open and close animation for the year picker?

@ArekChr
Copy link
Contributor

ArekChr commented Jun 19, 2023

Yes @mountiny, I will work on that.

@ArekChr
Copy link
Contributor

ArekChr commented Jun 19, 2023

Proposal

Problem Statement

The New Date Picker component has gone through several iterations, and refactoring is necessary to improve reusability across various flows and pages within the application.

Root Cause

The main issue lies in implementing the year list picker as a separate screen using react-navigation. This approach introduces additional complexity when navigating between the calendar and the year picker, resulting in various problems and regressions.

Proposed Solution

To address the problem effectively, I propose the following changes:

  1. Refactor the push-to-page screen to be a view within the calendar component. Integrating the year list picker directly into the calendar can eliminate complex navigation logic and simplify the overall implementation. This step includes:
  • Removing all related navigation logic in YearPickerPage and value selectedYear that comes from route props in DateOfBirthPage
  • Implementing a new logic to pass states between the list and calendar through props. Since navigation is removed, the following props in CalendarPicker will be removed: selectedMonth, selectedYear and onYearPickerOpen function. These props will be handled inside the CalendarPicker. Managing the state through props simplifies the use case, improves readability, and provides better testing possibilities for the year list picker.
  • Implementing an animation replicating the push-to-page screen's behaviour using reanimated. This ensures a seamless transition between the calendar and the year list, enhancing the overall usability of the component.
  1. Refactor the folder structure to improve component readability. Move the CalendarPicker folder into the NewDatePicker folder to ensure better organization and eliminate unused components.
  2. Refactor prop types as suggested in the discussion Feat: New Date Picker Design #15343 (comment). Move all prop types from the new date picker to its component since they are not exported elsewhere.
  3. Improve test coverage by utilizing the react-native-testing-library (RNTL). Add specific tests for selecting a year using the year picker within the calendar. This will facilitate easier testing of the year picker functionality and increase confidence in its behaviour.
  4. Introduce regression tests using RNTL and reassure to measure render counts and execution time when selecting a year and month and switching between months using arrow buttons. Monitoring these metrics will ensure optimal component performance and help identify potential regressions.

Implementing these proposed changes will enhance the reusability, maintainability, and overall quality of the NewDatePicker component. It will simplify the implementation, improve user experience, and increase test coverage, resulting in a more robust and reliable solution.

@mountiny
Copy link
Contributor Author

@ArekChr Thanks for the proposal, I think the plan looks good. I think the regression tests might not be that necessary at first they can come in a separate PRs for sure.

Lets ensure the UI of the page and animation using reanimated looks same as other page transitions.

Additionally I will ping @JmillsExpensify and @shawnborton here as they have been part of the previous discussions about the NewDatePicker component.

Do you have any concerns about the Year selector not being its own page anymore? It will simplify the code drastically, make it easy to reuse and understand which we both lack now. We doubt that the UX will be degraded. In case of Expense created date, users rarely even have to change year of the created date.

@ArekChr
Copy link
Contributor

ArekChr commented Jun 20, 2023

Great, so the regression tests from point 5 will be excluded.

@shawnborton
Copy link
Contributor

If the year picker is no longer push to page, how will it work exactly?

@ArekChr
Copy link
Contributor

ArekChr commented Jun 20, 2023

From a UX perspective, I am going to implement the same animation of pushing the page, so the user will not notice any UI difference.
From a DX perspective, the screen will be removed from the navigation stack.

@melvin-bot melvin-bot bot added the Awaiting Payment Auto-added when associated PR is deployed to production label Jul 13, 2023
@melvin-bot melvin-bot bot changed the title [Manual Requests] Make the Datepicker component more reusable [HOLD for payment 2023-07-20] [Manual Requests] Make the Datepicker component more reusable Jul 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.39-11 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-07-20. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@fedirjh] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@fedirjh] Determine if we should create a regression test for this bug.
  • [@fedirjh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@kevinksullivan] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 19, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Jul 21, 2023

@mountiny Do we need a checklist for this issue ?

@mountiny
Copy link
Contributor Author

No

@mountiny
Copy link
Contributor Author

@kevinksullivan this should be $1000 to @fedirjh for review and testing. thank you 🙇

@melvin-bot melvin-bot bot added the Overdue label Jul 24, 2023
@mountiny
Copy link
Contributor Author

@kevinksullivan this is ready to be paid

@melvin-bot melvin-bot bot removed the Overdue label Jul 24, 2023
@kevinksullivan kevinksullivan added the External Added to denote the issue can be worked on by a contributor label Jul 24, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-07-20] [Manual Requests] Make the Datepicker component more reusable [$1000] [HOLD for payment 2023-07-20] [Manual Requests] Make the Datepicker component more reusable Jul 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 24, 2023

Job added to Upwork: https://www.upwork.com/jobs/~018d352aca1b0ce802

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 24, 2023

Current assignee @kevinksullivan is eligible for the External assigner, not assigning anyone new.

@kevinksullivan
Copy link
Contributor

Just labeling to get the upwork job set up.

@melvin-bot
Copy link

melvin-bot bot commented Jul 24, 2023

Current assignees @ArekChr and @fedirjh are eligible for the External assigner, not assigning anyone new.

@kevinksullivan kevinksullivan removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2023
@kevinksullivan
Copy link
Contributor

Offer sent @fedirjh ^^ . Let me know when you accept!

@fedirjh
Copy link
Contributor

fedirjh commented Jul 24, 2023

@kevinksullivan Thank you! Accepted

@JmillsExpensify
Copy link

Woo! Awesome work on this one. Excited to have it in the wild.

@melvin-bot melvin-bot bot added the Overdue label Jul 26, 2023
@mountiny
Copy link
Contributor Author

@kevinksullivan All done here, can we close this?

@melvin-bot melvin-bot bot removed the Overdue label Jul 26, 2023
@kevinksullivan
Copy link
Contributor

All set / paid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants