Closed kbecciv closed 11 months ago
Job added to Upwork: https://www.upwork.com/jobs/~01d3bc058e2dff750b
Triggered auto assignment to @miljakljajic (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
Platforms
in OP are ✅)Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External
)
The issue was found during the execution of TR on step 10 https://expensify.testrail.io/index.php?/tests/view/3936772&group_by=cases:section_id&group_id=229063&group_order=asc
IOU - The last member is focused when I remove members
We always set newFocusedIndex = props.selectedOptions.length https://github.com/Expensify/App/blob/bc9cb8f8ca149c1f90dd09de9f19ae97bcaf07f0/src/components/OptionsSelector/BaseOptionsSelector.js#L116
We need to introduce new props called shouldFocusFirstSelectableMemberWhenUnselecting
(default false)
In here https://github.com/Expensify/App/blob/bc9cb8f8ca149c1f90dd09de9f19ae97bcaf07f0/src/components/OptionsSelector/BaseOptionsSelector.js#L116 if shouldFocusFirstSelectableMemberWhenUnselecting === true we will use new logic here
const disableSection = _.filter(this.props.sections, (section => section.isDisabled))
const disableLength = _.reduce(disableSection,
(accumulator, currentValue) => accumulator + currentValue.data.length,
0,
);
let newFocusedIndex = prevProps.selectedOptions.length < this.props.selectedOptions.length ? this.props.selectedOptions.length : disableLength;
if (prevProps.selectedOptions.length === this.props.selectedOptions.length) {
newFocusedIndex = this.state.focusedIndex
}
if shouldFocusFirstSelectableMemberWhenUnselecting === false we use old logic to ensure that this change won't break other flow
And then in MoneyRequestParticipantsSelector we will pass shouldFocusFirstSelectableMemberWhenUnselecting= true to OptionSelector Component
When user unselect member we should update focusIndex to the last selected member
The first unselected member is focused when removing members in multiselect
we set the newFocusedIndex to the last selected item: https://github.com/Expensify/App/blob/bc9cb8f8ca149c1f90dd09de9f19ae97bcaf07f0/src/components/OptionsSelector/BaseOptionsSelector.js#L116
in case of unselect we need to check if the new sections list lenght is smaller than the pre selection,
if this is the case then we can use the initialFocusedIndex
prop as the list in the splitWith is a special case where the first selected item is at index 1
not 0
additionally we need to adjust the default value of the initialFocusedIndex
to 0
so that it is fixed with all other components that use optionsSelector
const newFocusedIndex = prevProps.selectedOptions.length < this.props.selectedOptions.length ? this.props.selectedOptions.length : this.props.initialFocusedIndex;
const isNewFocusedIndex = newFocusedIndex !== this.state.focusedIndex;
// eslint-disable-next-line react/no-did-update-set-state
this.setState(
{
allOptions: newOptions,
focusedIndex: newFocusedIndex,
adjust this default value to 0
:
https://github.com/Expensify/App/blob/ebfc96a76f3d6e45c2c1ab954300547cb59f3715/src/components/OptionsSelector/optionsSelectorPropTypes.js#L177
and finally in the splitwith selector add
initialFocusedIndex={1}
this way in the case of unselect it will focus always on the initially focus index and in the case of select it will focus on the first unselected item.
Uploading Screen Recording 2023-11-03 at 5.33.55 PM.mov…
Not a bug, we always highlight the first unselected option.
@bernhardoj Could you help to link the discussion about it?
@DylanDylann Thanks for the proposal. Your RCA makes sense however the solution would break other cases where it's intended to focus the first unselected option e.g. when creating a new group from FAB.
https://github.com/Expensify/App/assets/16493223/93705f8b-10b5-41af-8f17-cd4e492c1ed9
@abzokhattab Thanks for the proposal but it's seems to be a dupe.
📣 @anzokhattab! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@s77rt not duplicate … i have used the initialFocusedIndex to set the focus .. where in the first proposal, the index 1 is always focused … there is a problem with this approach, it only works with the “split with” … it doesn’t work with search/add to group selection, therefore this is not a fully working solution.
my proposal works with other cases, please double check
Thanks
https://github.com/Expensify/App/assets/59809993/bb4c7697-533d-4822-af1e-6c539a0670bb
@s77rt Updated proposal
@abzokhattab The behavior on the group chat creation should not change. i.e. the focus should be on the first unselected option (and not the first option).
@DylanDylann Same not as above ^
@s77rt Oh got it. Updated proposal
@DylanDylann Thanks for the update. Introducing a new prop would probably open many ways to fix this bug but the fix would be done per instance basis. Can't we instead detect the change in the component itself e.g. use the number of sections. Or maybe have the focus always set to the first option of the second section.
@s77rt Could you help to confirm the expected first?
@DylanDylann I'm not totally sure here. I think we should first recheck whether this is a bug
Slack discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1699183749228599
Based on the slack discussion, this is the expected behavior. Let's just update the TR:
cc @miljakljajic
Not overdue. @miljakljajic ^
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
Not overdue. @miljakljajic https://github.com/Expensify/App/issues/30851#issuecomment-1793791157
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
Not overdue. @miljakljajic https://github.com/Expensify/App/issues/30851#issuecomment-1793791157
@miljakljajic ^
@s77rt @miljakljajic this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!
@s77rt, @miljakljajic Whoops! This issue is 2 days overdue. Let's get this updated quick!
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
Not looking for proposals. Just need to update TR. @miljakljajic https://github.com/Expensify/App/issues/30851#issuecomment-1793791157
@miljakljajic ^
@s77rt, @miljakljajic Whoops! This issue is 2 days overdue. Let's get this updated quick!
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@s77rt @miljakljajic this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:
Thanks!
Current assignee @s77rt is eligible for the Internal assigner, not assigning anyone new.
I'll update TestRail now! Thank you @s77rt !
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.3.95.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:
Expected Result:
The first member should be focused.
Actual Result:
The last member is focused when I remove members.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/Expensify/App/assets/93399543/6dea1e19-748f-4bca-ba24-c66fee444b23
View all open jobs on GitHub
Upwork Automation - Do Not Edit