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

[HOLD for payment 2024-09-21][$250] [Search v2.2] Keep status scroll position and update label sizes #47640

Closed
luacmartins opened this issue Aug 19, 2024 · 41 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

@luacmartins
Copy link
Contributor

luacmartins commented Aug 19, 2024

Coming from this PR, we need to address these comments:

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021833233716363835239
  • Upwork Job ID: 1833233716363835239
  • Last Price Increase: 2024-09-09
Issue OwnerCurrent Issue Owner: @mallenexpensify
@luacmartins luacmartins added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 19, 2024
@luacmartins luacmartins self-assigned this Aug 19, 2024
@luacmartins luacmartins added the External Added to denote the issue can be worked on by a contributor label Aug 19, 2024
Copy link

melvin-bot bot commented Aug 19, 2024

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

Copy link

melvin-bot bot commented Aug 19, 2024

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 19, 2024
Copy link

melvin-bot bot commented Aug 19, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

@luacmartins luacmartins mentioned this issue Aug 19, 2024
60 tasks
@luacmartins luacmartins assigned rayane-d and unassigned mananjadhav Aug 19, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 19, 2024
@nkdengineer
Copy link
Contributor

nkdengineer commented Aug 19, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

  1. The status scroll position isn't saved
  2. The label size of Expense dropdown button isn't correct

What is the root cause of that problem?

  1. When we click on status option, we open a new page and then SearchStatusBar is mounted again which makes the scroll position reset.

  2. The font size of Expense dropdown button isn't correct because it has the default font-size

What changes do you think we should make in order to solve the problem?

  1. To save the scroll position we can do the same way as we do in InitialSettingPage by using ScrollOffsetContext to store the scroll offset here, here and here. The route we pass to saveScrollOffset will be ROUTES.SEARCH_CENTRAL_PANE.route because we should use this for all search queries
const scrollViewRef = useRef<RNScrollView>(null);
const route = useRoute();
const {saveScrollOffset, getScrollOffset} = useContext(ScrollOffsetContext);

const onScroll = useCallback<NonNullable<ScrollViewProps['onScroll']>>(
    (e) => {
        // If the layout measurement is 0, it means the flashlist is not displayed but the onScroll may be triggered with offset value 0.
        // We should ignore this case.
        if (e.nativeEvent.layoutMeasurement.width === 0) {
            return;
        }
        saveScrollOffset(route, e.nativeEvent.contentOffset.x);
    },
    [saveScrollOffset, route],
);

useLayoutEffect(() => {
    const scrollOffset = getScrollOffset(route);
    if (!scrollOffset || !scrollViewRef.current) {
        return;
    }
    scrollViewRef.current.scrollTo({x: scrollOffset, animated: false});
}, [getScrollOffset, route]);

return (
    <ScrollView
        style={[styles.flexRow, styles.mb5, styles.overflowScroll, styles.flexGrow0]}
        horizontal
        onScroll={onScroll}
        ref={scrollViewRef}
        scrollEventThrottle={16}
        showsHorizontalScrollIndicator={false}
    >

  1. Update the font-size of the Expense button here by adding small prop for the icon and styles.fontSizeLabel for the title

What alternative solutions did you explore? (Optional)

NA

Result

Screen.Recording.2024-08-20.at.00.01.38.mov

@nkdengineer
Copy link
Contributor

Updated proposal

  • Add detail to save scroll position and add result

Copy link

melvin-bot bot commented Aug 19, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@bernhardoj
Copy link
Contributor

bernhardoj commented Aug 20, 2024

Edited by proposal-police: This proposal was edited at 2024-08-20 11:24:03 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

We want to fix 2 things.

  1. Update the Expense label and icon size
  2. Keep the scroll position for the search type when selecting the type

What is the root cause of that problem?

When we select the search type, for example Paid, the page loading which only renders the header and loading skeleton,

if (shouldShowLoadingState) {
return (
<>
<SearchPageHeader
isCustomQuery={isCustomQuery}
queryJSON={queryJSON}
hash={hash}
/>
<SearchRowSkeleton shouldAnimate />
</>
);
}

which means the SearchStatusBar is unmounted.

return (
<>
<SearchPageHeader
isCustomQuery={isCustomQuery}
queryJSON={queryJSON}
hash={hash}
onSelectDeleteOption={handleOnSelectDeleteOption}
data={data}
setOfflineModalOpen={() => setOfflineModalVisible(true)}
setDownloadErrorModalOpen={() => setDownloadErrorModalVisible(true)}
/>
<SearchStatusBar
type={type}
status={status}
/>
<SelectionListWithModal<ReportListItemType | TransactionListItemType>

and when the loading is completed, a new SearchStatusBar instance is mounted.

For the styling issue, it's just we don't apply the correct styling.

What changes do you think we should make in order to solve the problem?

To keep the SearchStatusBar mounted even when loading, we need to add SearchStatusBar when loading too.

if (shouldShowLoadingState) {
return (
<>
<SearchPageHeader
isCustomQuery={isCustomQuery}
queryJSON={queryJSON}
hash={hash}
/>
<SearchRowSkeleton shouldAnimate />

<SearchPageHeader />
<SearchStatusBar />
<SearchRowSkeleton />

Just like we did with an empty view too.

if (shouldShowEmptyState) {
return (
<>
<SearchPageHeader
isCustomQuery={isCustomQuery}
queryJSON={queryJSON}
hash={hash}
/>
<SearchStatusBar
type={type}
status={status}
/>
<EmptySearchView type={type} />
</>

This way, the component tree for the header and status bar stays the same which prevents it from being unmounted.

|
|-Header
|-StatusBar
|-Skeleton/EmptyView/SelectionList

For the Expenses button style issue, the button height is actually 42 instead of 40. We can update the pressable and view height here to 40.

<PressableWithFeedback
accessible
accessibilityLabel={popoverMenuItems[activeItemIndex]?.text ?? ''}
ref={buttonRef}
style={[styles.tabSelectorButton, styles.ph5]}
wrapperStyle={styles.flex1}
onPress={openMenu}
>
{({hovered}) => (
<Animated.View style={[styles.tabSelectorButton, styles.tabBackground(hovered, true, theme.border), styles.w100, styles.mh3]}>

And to make the icon 16px, we need to pass small or medium and hasText props to the Icon. And for the text, we need to pass styles.fontSizeLabel style so the font size is 13px.

<Icon
src={menuIcon}
fill={theme.icon}
/>
<Text
numberOfLines={1}
style={[styles.textStrong, styles.flexShrink1]}
>
{menuTitle}
</Text>
<Icon
src={Expensicons.DownArrow}
fill={theme.icon}
/>

Alternatively, we can replace the pressable with ButtonWithDropdownMenu. So, we can replace

<PressableWithFeedback
accessible
accessibilityLabel={popoverMenuItems[activeItemIndex]?.text ?? ''}
ref={buttonRef}
style={[styles.tabSelectorButton, styles.ph5]}
wrapperStyle={styles.flex1}
onPress={openMenu}
>
{({hovered}) => (
<Animated.View style={[styles.tabSelectorButton, styles.tabBackground(hovered, true, theme.border), styles.w100, styles.mh3]}>
<View style={[styles.flexRow, styles.gap2, styles.alignItemsCenter, titleViewStyles]}>
<Icon
src={menuIcon}
fill={theme.icon}
/>
<Text
numberOfLines={1}
style={[styles.textStrong, styles.flexShrink1]}
>
{menuTitle}
</Text>
<Icon
src={Expensicons.DownArrow}
fill={theme.icon}
/>
</View>
</Animated.View>
)}
</PressableWithFeedback>
<PopoverMenu
menuItems={popoverMenuItems}
isVisible={isPopoverVisible}
anchorPosition={styles.createMenuPositionSidebar(windowHeight)}
onClose={closeMenu}
onItemSelected={closeMenu}
anchorRef={buttonRef}
/>

with

<ButtonWithDropdownMenu
    onPress={() => null}
    shouldAlwaysShowDropdownMenu
    buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM}
    options={popoverMenuItems}
    isSplitButton={false}
    icon={menuIcon}
    style={[styles.ph5]}
    wrapperStyle={styles.flex1}
/>

To scroll into the selected status every time we refresh or deeplink to the page, we can scroll to the button position when the component is first mounted.

First, we can use onLayout, which we pass to the button. The Button needs to receive the onLayout props and pass it to the pressable.

onLayout={(e) => {
    if (!isActive || isScrolledRef.current) {
        return
    }
    isScrolledRef.current = true;
    ref.current?.scrollTo({x: e.nativeEvent.layout.left});
}}

If the item isn't selected (isActive is false), then we don't scroll to that item. Also, we only want this to happen once, so we use isScrolledRef to keep track of that.

@rayane-d
Copy link
Contributor

Hi @nkdengineer and @bernhardoj,

In this PR, we will be adding a loading skeleton to the status bar. According to this discussion, we will keep the status bar mounted while changing the status. The status bar skeleton will only be shown while loading or changing the type (e.g., expense, invoice, trip).

Regarding the status scroll issue, We need to ensure that the selected status button (e.g., Paid status button) remains visible if we deeplink to a URL like https://dev.new.expensify.com:8082/search?q=type%3Aexpense%20status%3Apaid or when the page is refreshed.

Could you please update your proposals based on these details?

@bernhardoj
Copy link
Contributor

Updated my proposal to scroll to the selected status bar.

@rayane-d
Copy link
Contributor

We need to put this on hold for #47753 and #47515 as #47181 was reverted

@rayane-d rayane-d mentioned this issue Aug 23, 2024
60 tasks
@melvin-bot melvin-bot bot added the Overdue label Aug 23, 2024
@rayane-d
Copy link
Contributor

Still on hold for #47753 and #47515

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Aug 23, 2024
@rayane-d
Copy link
Contributor

same ^

@melvin-bot melvin-bot bot removed the Overdue label Aug 26, 2024
Copy link

melvin-bot bot commented Sep 9, 2024

Current assignee @rayane-djouah is eligible for the External assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 10, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @rayane-djouah

@luacmartins luacmartins changed the title [$250] [Search v2.2] Keep status scroll position and update label sizes [HOLD for payment 2024-09-21][$250] [Search v2.2] Keep status scroll position and update label sizes Sep 16, 2024
@luacmartins luacmartins added Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 and removed Reviewing Has a PR in review Weekly KSv2 labels Sep 16, 2024
@luacmartins luacmartins moved this from Polish to Done in [#whatsnext] #expense Sep 16, 2024
@melvin-bot melvin-bot bot added the Overdue label Sep 19, 2024
Copy link

melvin-bot bot commented Sep 20, 2024

@luacmartins, @mallenexpensify, @bernhardoj, @rayane-djouah Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

Copy link

melvin-bot bot commented Sep 21, 2024

Payment Summary

Upwork Job

BugZero Checklist (@mallenexpensify)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1833233716363835239/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@luacmartins
Copy link
Contributor Author

Payment due

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

@mallenexpensify can I get a payment summary?

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Sep 23, 2024

Contributor: @bernhardoj owed $250 via Upwork
Contributor+: @rayane-djouah paid $250 via NewDot

@bernhardoj can you please accept the job and reply here once you have?
https://www.upwork.com/jobs/~021833233716363835239

@rayane-djouah plz complete the BZ checklist.

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:

  • [@] The PR that introduced the bug has been identified. Link to the PR:
  • [@] 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:
  • [@] 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:
  • [@] Determine if we should create a regression test for this bug.
  • [@] 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.
  • [@bz] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot removed the Overdue label Sep 23, 2024
@bernhardoj
Copy link
Contributor

@mallenexpensify I've requested the payment via ND.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Daily KSv2 labels Sep 23, 2024
@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@rayane-d
Copy link
Contributor

Checklist

  • The PR that introduced the bug has been identified. Link to the PR: This is a follow-up to this PR: Create status bar #47181 to address these comments: Create status bar #47181 (comment), Create status bar #47181 (comment)
  • 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: The author and reviewers are aware already: Create status bar #47181 (comment)
  • 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: N/A
  • Determine if we should create a regression test for this bug. I propose a regression test for the status bar auto-scrolling issue; the styling part will be handled during project wrap-up.
  • 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.

Regression Test Proposal

  • On mWeb Safari/Chrome:
  1. Open the Search page.
  2. Switch to "Paid" status on the status bar.
  3. Refresh the page.
  4. Verify that the status bar scrolls to the "Paid" button and the button is fully visible.

Do we agree 👍 or 👎

@rayane-d
Copy link
Contributor

@mallenexpensify - Applied to the Upwork job

@mallenexpensify
Copy link
Contributor

@rayane-djouah can you please accept the job and reply here once you have?
https://www.upwork.com/jobs/~021833233716363835239

Sorry, I thought I 'hired' you earlier, not just invited you.

Test case created

@rayane-d
Copy link
Contributor

@mallenexpensify - Accepted, thank you!

@mallenexpensify
Copy link
Contributor

Thanks @rayane-djouah , you're paid, payment comment updated above.

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
Archived in project
Development

No branches or pull requests

9 participants