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 on PR #34196] [$500] Profile -The preselected pronoun isn't highlighted by default #34749

Closed
2 of 6 tasks
lanitochka17 opened this issue Jan 18, 2024 · 21 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 18, 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: 1.4.27-0
Reproducible in staging?: Y
Reproducible in production?: Y
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open Expensify App
  2. Log in
  3. Navigate to settings by tapping on the user avatar
  4. Tap on Profile and then Pronouns
  5. Search and select a pronoun
  6. Tap again Pronouns
  7. Verify if the preselected pronoun is highlighted

Expected Result:

The selected pronouns should have been highlighted by default when there is no searching performed (as in the timezone selection)

Actual Result:

Only green checkmark exist in the preselected pronoun, but it is not highlighted (both if there is no search or after search)

Workaround:

Unknown

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

Bug6346771_1705598027784.mobizen_20240118_191252.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01af844a0a64bbba29
  • Upwork Job ID: 1748037184016420864
  • Last Price Increase: 2024-01-25
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 18, 2024
@melvin-bot melvin-bot bot changed the title Profile -The preselected pronoun isn't highlighted by default [$500] Profile -The preselected pronoun isn't highlighted by default Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01af844a0a64bbba29

Copy link

melvin-bot bot commented Jan 18, 2024

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

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

melvin-bot bot commented Jan 18, 2024

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

@aeioual
Copy link
Contributor

aeioual commented Jan 18, 2024

Proposal

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

The preselected pronoun isn't highlighted by default

What is the root cause of that problem?

In the BaseSelectionList component, here we forget to reverify whether initiallyFocusedOptionKey is available.

useEffect(() => {
// do not change focus on the first render, as it should focus on the selected item
if (isInitialSectionListRender) {
return;
}
// set the focus on the first item when the sections list is changed
if (sections.length > 0) {
updateAndScrollToFocusedIndex(0);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sections]);

This always defaults the updateAndScrollToFocusIndex to the Index 0

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

we should make the following changes before setting the updateAndScrollToFocusIndex value:

if (sections.length > 0) {

  const currentSelection = _.findIndex(
    flattenedSections.allOptions, (option) =>
    option.keyForList === initiallyFocusedOptionKey)

  updateAndScrollToFocusedIndex(currentSelection ?? 0);
}

The condition currentSelection ?? 0 checks if currentSelection is null or undefined (indicating that the specified option was not found), it defaults to 0.

Test branch with implemented functionality can be found here: Test Branch

What alternative solutions did you explore? (Optional)

N/A

@esh-g
Copy link
Contributor

esh-g commented Jan 18, 2024

Proposal

Please re-state the issue we are trying to solve

The preselected pronoun isn't highlighted by default after searching.

What is the root cause of this issue?

The root cause is that we don't recheck if initallyFocusedOptionKey is present after the first render. So after changing search text, we just focus to the 0 index and don't look for that initallyFocusedOptionKey

What changes should be made to fix this?

We should modify this:

// set the focus on the first item when the sections list is changed
if (sections.length > 0) {
updateAndScrollToFocusedIndex(0);
}

To:

// set the focus on the first item when the sections list is changed
if (sections.length > 0) {
    const initallyFocused = _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey)
    updateAndScrollToFocusedIndex(initallyFocused ?? 0);
}

This will check for the initialItem every time sections update.

Result

Screen.Recording.2024-01-18.at.11.27.32.PM.mov

@ikevin127
Copy link
Contributor

Might be regression from #30438.

A PR #34196 is already opened that will tackle that regression. Another issue #34300 that I was told will be fixed by the opened PR.

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Jan 18, 2024

Proposal

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

Profile -The preselected pronoun isn't highlighted by default

What is the root cause of that problem?

The main problem with issue is that when we open pronoun screen
we have a case where we initially have an empty array
And we keep the index -1

const [focusedIndex, setFocusedIndex] = useState(() => _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey));

But then when we update section list we can't change index
Because we still have isInitialSectionListRender is true

useEffect(() => {
// do not change focus on the first render, as it should focus on the selected item
if (isInitialSectionListRender) {
return;
}
// set the focus on the first item when the sections list is changed
if (sections.length > 0) {
updateAndScrollToFocusedIndex(0);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sections]);

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

To fix this issue we can just update the code and update the index when we still have isInitialSectionListRender === true

        if (isInitialSectionListRender) {
            setFocusedIndex(flattenedSections.allOptions.findIndex((option) => option.keyForList === initiallyFocusedOptionKey));
            return;
        }

if (isInitialSectionListRender) {
return;
}

Using the logic from focusedIndex initialization

const [focusedIndex, setFocusedIndex] = useState(() => _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey));

What alternative solutions did you explore? (Optional)

NA

@DylanDylann
Copy link
Contributor

Proposal

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

The selected pronouns should have been highlighted by default when there is no searching performed (as in the timezone selection)

Currently the selected option isn't highlighted right after user go to pronouns page (don't type anything on search input)

Screenshot 2024-01-19 at 15 04 52

In addition, When user type in the search input, It makes sense to focus on the first option

What is the root cause of that problem?

Let's see here

const [focusedIndex, setFocusedIndex] = useState(() => _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey));

We are setting the default value for focusedIndex in the param of useState hook, with this approach the default value only be calculated in the first render. But in the first render flattenedSections.allOptions is empty

Screenshot 2024-01-19 at 15 08 55

Even though, after flattenedSections.allOptions is updated the focusedIndex will not be calculated again

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

We should use a useEffect to calculate focusedIndex again when flattenedSections.allOptions change

const [focusedIndex, setFocusedIndex] = useState(() => _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey));

    useEffect(() => {
        const newFocusedIndex = _.findIndex(flattenedSections.allOptions, (option) => return option.keyForList === initiallyFocusedOptionKey)
        setFocusedIndex(newFocusedIndex)
    },[flattenedSections.allOptions, initiallyFocusedOptionKey])


What alternative solutions did you explore? (Optional)

NA

Result

Screenshot 2024-01-19 at 15 12 28

@fedirjh
Copy link
Contributor

fedirjh commented Jan 24, 2024

This will be fixed with #34196, screenshot from PR branch :

CleanShot.2024-01-24.at.09.56.03.mp4

@melvin-bot melvin-bot bot removed the Overdue label Jan 24, 2024
Copy link

melvin-bot bot commented Jan 25, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Jan 29, 2024

On hold for #34196

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 29, 2024
@muttmuure muttmuure changed the title [$500] Profile -The preselected pronoun isn't highlighted by default [HOLD on PR #34196] [$500] Profile -The preselected pronoun isn't highlighted by default Jan 31, 2024
@muttmuure
Copy link
Contributor

Not overdue

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 31, 2024
@muttmuure
Copy link
Contributor

Held

@melvin-bot melvin-bot bot removed the Overdue label Feb 5, 2024
@melvin-bot melvin-bot bot added the Overdue label Feb 8, 2024
Copy link

melvin-bot bot commented Feb 9, 2024

@fedirjh, @muttmuure Whoops! This issue is 2 days overdue. Let's get this updated quick!

@muttmuure
Copy link
Contributor

@fedirjh any closer on the linked PR?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 9, 2024
@muttmuure
Copy link
Contributor

muttmuure commented Feb 12, 2024

Still waiting on the linked PR

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 12, 2024
Copy link

melvin-bot bot commented Feb 16, 2024

@fedirjh, @muttmuure Whoops! This issue is 2 days overdue. Let's get this updated quick!

@fedirjh
Copy link
Contributor

fedirjh commented Feb 17, 2024

#34196 is deployed to staging.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 17, 2024
Copy link

melvin-bot bot commented Feb 21, 2024

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

@fedirjh
Copy link
Contributor

fedirjh commented Feb 21, 2024

@muttmuure This issue was fixed with #34196, can you please retest and close?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 21, 2024
@muttmuure
Copy link
Contributor

Yep, looks good

@melvin-bot melvin-bot bot removed the Overdue label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

8 participants