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-07-10] [$250] [Search v1] Apply hover style to row if button is hovered #43233

Closed
6 tasks
luacmartins opened this issue Jun 6, 2024 · 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

@luacmartins
Copy link
Contributor

luacmartins commented Jun 6, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number:
Reproducible in staging?:
Reproducible in production?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by:
Slack conversation:

Action Performed:

Coming from this comment

  1. Navigate to the new search page
  2. Hover a row
  3. Notice that it is highlighted
  4. Hover the button within the row
  5. Notice that the button is highlighted but the row is no longer highlighted

Expected Result:

Row should be highlighted

Actual Result:

Row is not highlighted

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013a5b2e0e021c1c12
  • Upwork Job ID: 1798845264683098328
  • Last Price Increase: 2024-07-15
  • Automatic offers:
    • alitoshmatov | Reviewer | 102798152
    • dominictb | Contributor | 102798154
Issue OwnerCurrent Issue Owner: @dylanexpensify
@luacmartins luacmartins added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 6, 2024
@luacmartins luacmartins self-assigned this Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

Triggered auto assignment to @dylanexpensify (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.

@luacmartins luacmartins added the External Added to denote the issue can be worked on by a contributor label Jun 6, 2024
@melvin-bot melvin-bot bot changed the title [Search v1] Apply hover style to row if button is hovered [$250] [Search v1] Apply hover style to row if button is hovered Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

Job added to Upwork: https://www.upwork.com/jobs/~013a5b2e0e021c1c12

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

melvin-bot bot commented Jun 6, 2024

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

@luacmartins luacmartins changed the title [$250] [Search v1] Apply hover style to row if button is hovered [$125] [Search v1] Apply hover style to row if button is hovered Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

Upwork job price has been updated to $125

@BishalN
Copy link

BishalN commented Jun 7, 2024

Contributor details
Your Expensify account email: neupanebishal07@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01182d696a155c95ce

Copy link

melvin-bot bot commented Jun 7, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@dominictb
Copy link
Contributor

dominictb commented Jun 7, 2024

Proposal

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

Row is not highlighted

What is the root cause of that problem?

When we hover on a Pressable nested inside another Pressable, by default it will trigger onHoverOut of the outer Pressable. This is a react-native-web feature when the contain here is true, so when another Pressable is hovered, the current hovered Pressable will automatically lose hover state, even though the newly hovered element is inside the previously hovered element, and the browser doesn't dispatch any pointerleave event on the previously hovered element. From the POV the parent component is still hovered, but react-native-web still triggers the onHoverOut for the above reason.

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

In

, if event.type is pointerenter or mouseenter, that means the hover is lost due to user entering a Pressable inside the current component, early return because the hover is still inside the current component. Alternatively we can add a prop to control this behavior like allowNestedHover.

if (event?.type === 'pointerenter' || event?.type === 'mouseenter') {
    return;
}

Then isHovered needs to be passed as prop to GenericPressable and in this, hoverStyle will also be applied if isHovered is true

(There're other ways to check like: check the target of the event is inside the current component)

Optionally, we can do the same in

, if isHovered is already true, early return

What alternative solutions did you explore? (Optional)

Add a PR upstream in react-native-web so we can control the contain here via a prop. Then we can set it to false by using the prop of Pressable. If it's false, hovering on the nested button will still keep the hover on the parent button.

@dominictb
Copy link
Contributor

Updated proposal to add an alternative solution

@dragnoir
Copy link
Contributor

dragnoir commented Jun 7, 2024

Proposal

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

Child hover effect not detected by parent Pressable

What is the root cause of that problem?

By default, we don't have a system or a feature that let hovered child Pressable, keep the hover style of a parent Pressable

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

On this PR #42823 I created a mouseContext to help elimanate the issue between parent and child when there's a mouseup/moueUp/mouseDown event.

We can use the same context and add a new feature for child hover state

import type { ReactNode } from 'react';
import React, { createContext, useContext, useMemo, useState } from 'react';

type MouseContextProps = {
  isMouseDownOnInput: boolean;
  setMouseDown: () => void;
  setMouseUp: () => void;
  isChildHovered: boolean;
  setChildHover: () => void;
  setChildLeave: () => void;
};

const MouseContext = createContext<MouseContextProps>({
  isMouseDownOnInput: false,
  setMouseDown: () => {},
  setMouseUp: () => {},
  isChildHovered: false,
  setChildHover: () => {},
  setChildLeave: () => {},
});

type MouseProviderProps = {
  children: ReactNode;
};

function MouseProvider({ children }: MouseProviderProps) {
  const [isMouseDownOnInput, setIsMouseDownOnInput] = useState(false);
  const [isChildHovered, setIsChildHovered] = useState(false);

  const setMouseDown = () => setIsMouseDownOnInput(true);
  const setMouseUp = () => setIsMouseDownOnInput(false);

  const setChildHover = () => setIsChildHovered(true);
  const setChildLeave = () => setIsChildHovered(false);

  const value = useMemo(
    () => ({
      isMouseDownOnInput,
      setMouseDown,
      setMouseUp,
      isChildHovered,
      setChildHover,
      setChildLeave,
    }),
    [isMouseDownOnInput, isChildHovered]
  );

  return <MouseContext.Provider value={value}>{children}</MouseContext.Provider>;
}

const useMouseContext = () => useContext(MouseContext);

export { MouseProvider, useMouseContext };

Then with this mouse context, we can fix all the BaseListItem components, where the effect will be also applied to other UIs like (where we have the same issue)

image

image

Using the new context, we can use to encapsulate the BaseListItem component, then:

  • on the child component, we add:
onMouseEnter={setChildHover} 
onMouseLeave={setChildLeave}
  • on the parent component we change the hover state based on the new state from the context

hoverStyle={[!item.isDisabled && styles.hoveredComponentBG, hoverStyle]}

What alternative solutions did you explore?

@dominictb
Copy link
Contributor

Updated proposal to add some details

@trjExpensify
Copy link
Contributor

@alitoshmatov can you review these proposals, please? Thanks!

Copy link

melvin-bot bot commented Jun 10, 2024

@luacmartins, @alitoshmatov, @dylanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@dylanexpensify
Copy link
Contributor

bump @alitoshmatov

Copy link

melvin-bot bot commented Jun 12, 2024

@luacmartins, @alitoshmatov, @dylanexpensify Huh... This is 4 days overdue. Who can take care of this?

@alitoshmatov
Copy link
Contributor

alitoshmatov commented Jun 13, 2024

@luacmartins Should this logic applied everywhere - Parent hover should be active when cursor is on pressable element

We have similar case
Search page:

Screen.Recording.2024-06-13.at.3.59.49.PM.mov

Workspace list:

Screen.Recording.2024-06-13.at.4.02.38.PM.mov

@melvin-bot melvin-bot bot removed the Overdue label Jun 13, 2024
@alitoshmatov
Copy link
Contributor

alitoshmatov commented Jun 13, 2024

@dominictb Thank you for your proposal, I really like the your first solution but it is not working for me can you recheck it?

Applying early return:

if (event?.type === 'pointerenter' || event?.type === 'mouseenter') {
    return;
}

@alitoshmatov
Copy link
Contributor

@dragnoir Thank you for your proposal, I think your solution is not directly solving the problem we should change the behavior of hover element when it contains pressable element. I think your solution is adding a new behavior to each element manually.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 24, 2024
@dylanexpensify
Copy link
Contributor

dylanexpensify commented Jul 3, 2024

Waiting for regression period!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 3, 2024
@melvin-bot melvin-bot bot changed the title [$125] [Search v1] Apply hover style to row if button is hovered [HOLD for payment 2024-07-10] [$125] [Search v1] Apply hover style to row if button is hovered Jul 3, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

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

Copy link

melvin-bot bot commented Jul 3, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 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 2024-07-10. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 3, 2024

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:

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

@alitoshmatov
Copy link
Contributor

Regression Test Proposal

  1. Go to search page
  2. Hover the row
  3. Notice it is highlighted
  4. Hover View button inside the row
  5. Make sure both button and row is highlighted(showing hover style)

Do we agree 👍 or 👎

@dylanexpensify
Copy link
Contributor

payment coming up!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 10, 2024
@dylanexpensify
Copy link
Contributor

dylanexpensify commented Jul 12, 2024

Payment summary:

Please apply/request!

@dylanexpensify
Copy link
Contributor

@dominictb please accept offer! 🙇‍♂️

@melvin-bot melvin-bot bot added the Overdue label Jul 15, 2024
@dominictb
Copy link
Contributor

@luacmartins @dylanexpensify Could we keep the $250 original price for this issue?

I saw it being reduced by half, however I believe this is not a simple issue, it requires non-intuitive use of mouse event, and I needed to dig into the library being used to find the RCA. Also there was a request to fix all cases of Pressables across the app and we've done that, it requires a lot of testing to make sure there's no regression.

Appreciate your thought on this one!

@luacmartins
Copy link
Contributor Author

Sure, we can keep this one at the regular bounty.

@luacmartins luacmartins changed the title [HOLD for payment 2024-07-10] [$125] [Search v1] Apply hover style to row if button is hovered [HOLD for payment 2024-07-10] [$250] [Search v1] Apply hover style to row if button is hovered Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

Upwork job price has been updated to $250

@dylanexpensify
Copy link
Contributor

Nice, @dominictb accept the offer as it is, and I'll add another $125 as a bonus! @alitoshmatov I'll send a bonus for same amount to you as well!

@melvin-bot melvin-bot bot removed the Overdue label Jul 15, 2024
@dominictb
Copy link
Contributor

Thank you @luacmartins @dylanexpensify

I accepted the offer

@dylanexpensify
Copy link
Contributor

Nice, paying!

@dylanexpensify
Copy link
Contributor

all done!

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

No branches or pull requests

9 participants