Closed m-natarajan closed 3 months ago
Triggered auto assignment to @Christinadobrzyn (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.
Split bill / Group chat - When selecting the user search input should clear query and search input should be focused
New feature
We need to set the searchTerm
to empty value when addParticipantToSelection
is called and similarly in NewChatPage
when toggleOption
is called.
https://github.com/Expensify/App/blob/42d4ed7b72dc979df430a2a7eac4ba30a3eac790/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js#L213
https://github.com/Expensify/App/blob/42d4ed7b72dc979df430a2a7eac4ba30a3eac790/src/pages/NewChatPage.tsx#L218
We can introduce a new prop clearSearchOnLengthChange
to clear the input when selected options change. To make this work we need to clear the input search when clearSearchOnLengthChange
changes. We can't clear search when selectRow
in SelectionList
is called because selected options can be changed by the rightHandSideComponent
, like in NewChatPage
and in components like these selectRow
isn't called to select/deselect options.
To make this work with all components, we need to follow few steps:
clearSearchOnLengthChange
in SelectionList
, this prop will accept a number as input.useEffect
function to clear the search input text using onChangeText
when clearSearchOnLengthChange
is changed.
const previousSelectedOptions = usePrevious(clearSearchOnLengthChange);
useEffect(() => {
if (previousSelectedOptions === clearSearchOnLengthChange || !onChangeText) {
return;
}
onChangeText('');
}, [clearSearchOnLengthChange, onChangeText, previousSelectedOptions]);
clearSearchOnLengthChange
prop all the components which needs this functionality.I can reproduce but I'm a little unsure what is expected here... asking in Slack. https://expensify.slack.com/archives/C049HHMV9SM/p1714112524451069?thread_ts=1714064614.847909&cid=C049HHMV9SM
I think this might be external
Job added to Upwork: https://www.upwork.com/jobs/~012a1b93a6a141243d
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (External
)
The search input doesn't clear, so even after you select someone, you have no context in terms of how many other people were selected or who else is available to be selected
When we select an option, we don't have the logic to clear the search.
If we apply this logic, we should apply it for all search page that can select multiple options like RoomInvitePage
, NewChatPage
, MoneyTemporaryForRefactorRequestParticipantsSelector
, .... So in SelectionList
we can add an extra prop like shouldClearInputOnSelect
with default is false
.
If it's true
we will clear the text input when we select an option by adding this logic in selectRow
function here
if (shouldShowTextInput && shouldClearInputOnSelect && canSelectMultiple) {
onChangeText?.('');
}
And then we can add shouldClearInputOnSelect
prop true
into SelectionList
in any page that we want to clear the search input after selecting an option.
If we want to always clear the search input when we can select multiple option, we can add the logic like this to selectRow
function here. With this we don't need to add a new prop.
if (shouldShowTextInput && canSelectMultiple) {
onChangeText?.('');
}
Proposal:
Problem: Missing information regarding the total number of users selected and/or which users are already selected.
Root Cause: Search input doesn't clear itself after user selection. No information about the total number of users selected.
Solution:
The above measures should solve the all issues in terms of logic as well as positive feedback on the UI for the user to understand what is going on.
π£ @Ammar946! π£ 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>
Contributor details Your Expensify account email: ammarshahbaz413@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~010ec655f2a9846693
β Contributor details stored successfully. Thank you for contributing to Expensify!
We should clarify expected behavior. I think clearing search query is not a right choice, In my opinion search query should stay and not be cleared when user is selected but we should just show all selected users
I think clearing search query is not a right choice, In my opinion search query should stay and not be cleared when user is selected but we should just show all selected users
I think after discussing it in Slack we came to a different conclusion. Most of the time when searching in these invite/add people flows, you are just searching for the next contact you want to select, not multiple. I think we should try it out with clearing the search input after you select someone and see how it feels from there.
Thanks @shawnborton! Just asked in our Slack thread (so not to clutter here if I'm wrong) of what this should look like, can you take a peek and confirm and I'll add the expected behaviour here.
Confirmed over there!
thank you! @alitoshmatov the expected behaviour is:
Here's a sloppy video of what we're looking for:
https://github.com/Expensify/App/assets/51066321/df6ca97b-e399-4b0e-9f13-d2158176f60b
Let me know if that helps!
@Krishna2323 Thank you for your proposal. But I think this feature is not only for split bill. It should be handled on all places where you select multiple users as stated in original slack post:
Go through a flow where you can select multiple users, for instance Splitting an expense, or inviting members to a workspace
@nkdengineer Thank you for your proposal. Your RCA is correct and your solution does work. I think we should implement this to everywhere where you can select multiple users.
We can go with @nkdengineer 's proposal
C+ reviewed π π π
Triggered auto assignment to @MonilBhavsar, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@alitoshmatov, don't we need this feature on new chat page? We can select multiple users there also for creating groups but onSelecRow
isn't called there because the selection is handled by rightHandSide
component. Please recheck my alternative solution.
That makes sense, yeah. Basically anywhere that has this multi-select functionality, we should do it.
Agree π We should find and update all of them
To fix for all cases, we can create a useEffect to clear the text input when the selectedOptions length is changed. we already have prevSelectedOptionsLength
in BaseSelectionList
so we don't need to define a new prop.
useEffect(() => {
if (prevSelectedOptionsLength === flattenedSections.selectedOptions.length || !texInputValue) {
return;
}
onChangeText?.('');
}, [prevSelectedOptionsLength, flattenedSections.selectedOptions.length, onChangeText, texInputValue])
@shawnborton I have another question here:
Should we only clear the input if we only have one option to select when searching?
For example in this case, when I search and have many contacts here and select one of them. It will not make sense if we clear the input here because maybe we want to select some users of them. So I think it makes sense if we only clear the input when we only have one option to select.
https://github.com/Expensify/App/assets/161821005/8d905c17-f2d3-494e-9a9f-f7372be4a984
We want to clear it even if there are multiple search results. The case we are optimizing for is that you are selecting likely different individuals each time, not multiple people with a similar email address.
I made a similar clarifying comment above for reference.
@nkdengineer @alitoshmatov, FYI, the condition below won't work as expected because the number of selected options depends entirely on the search input. If the search result doesn't include the currently selected options, it will change.
if (prevSelectedOptionsLength === flattenedSections.selectedOptions.length || !texInputValue) {
return;
}
onChangeText?.('');
Working through proposals
hi @MonilBhavsar @alitoshmatov do you have an update on this? TY!
We're awaiting a review from @alitoshmatov here after a proposal update
I think listening to list items length is a workaround and might be confusing in the future. I think we should clearing input inside selectRow
and implement separate solution for new page. What do you think
cc: @Krishna2323 @MonilBhavsar @nkdengineer
@alitoshmatov, I don't think it looks like a workaround, it is just like shouldClearInputOnSelect
prop. IMO we should clear the input from one place instead of multiple because it will be confusing and might cause regressions in future, specifically when using SelectionList
with rightHandSideComponent
.
@MonilBhavsar @Christinadobrzyn @alitoshmatov this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Agree, these both solutions seems like a workaround - https://github.com/Expensify/App/issues/41049#issuecomment-2091033092 and https://github.com/Expensify/App/issues/41049#issuecomment-2078487320 Listening to options length and adding a new prop and comparing options with it.
The workflow we want here is user typing user's login and then selecting. Once selected, we want to clear the input. Why not add a event when user is selected and clear the input. I see those in the proposals. What are we missing in those proposals?
The workflow we want here is user typing user's login and then selecting. Once selected, we want to clear the input. Why not add a event when user is selected and clear the input. I see those in the proposals. What are we missing in those proposals?
@MonilBhavsar As my alternative solution here https://github.com/Expensify/App/issues/41049#issuecomment-2078764528, We will clear the input in selectRow
function which is called when a user is selected and that will work for all multiple selection list. But the problem is in NewChatPage
, the Add to group button
is rendered as rightHandComponent
and it has a separate onPress
event that doesn't call selectRow
function.
Do you agree with my alternative solution and implement separate solution for new page as suggestion from @alitoshmatov here https://github.com/Expensify/App/issues/41049#issuecomment-2101217776?
@MonilBhavsar @alitoshmatov, could you please explain why you feel that passing the length of selected options and clearing the search input when the length changes seems like a workaround to you? I believe that passing selected options length isn't a workaround, we will clear the input whenever the prop changes.
PS: I pointed out that the other proposal will not work on all pages, and my proposal was the first to suggest using a separate solution for pages because selectRow
isn't called when we use rightHandSideComponent. However, I'm still inclined to pass the selected options length and clear the input based on that.
@MonilBhavsar, @Christinadobrzyn, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?
@MonilBhavsar and @alitoshmatov can you check out this question? https://github.com/Expensify/App/issues/41049#issuecomment-2106953342
Are we looking for additional proposals?
@nkdengineer @alitoshmatov I agree with this comment https://github.com/Expensify/App/issues/41049#issuecomment-2106890729
I am thinking of defining a callback function that clears the input when passed from the button/handler. We define it once and call it from selectable item in selection list and from "Add to group button" and achieve the expected functionality. Can we do that? Are there only two places inside the App where we need to implement this?
could you please explain why you feel that passing the length of selected options and clearing the search input when the length changes seems like a workaround to you? I believe that passing selected options length isn't a workaround, we will clear the input whenever the prop changes.
We're triggering a function on an indirect change of events(change in options length) rather than a direct user action(clicking on option row or button). I think that makes code less easy to read and walkthrough.
@MonilBhavsar We can define a function like clearInputAfterSelect
and share this via the ref.
const clearInputAfterSelect = useCallback(() => {
onChangeText?.('');
}, [onChangeText])
useImperativeHandle(ref, () => ({scrollAndHighlightItem, clearInputAfterSelect}), [scrollAndHighlightItem, clearInputAfterSelect]);
And then we will call this function when we select a row here
if (canSelectMultiple && shouldShowTextInput) {
clearInputAfterSelect();
}
For the case of NewChatPage
, we will create a ref for selection list and call clearInputAfterSelect
when we toggle Add to group
button
const selectionListRef = useRef<SelectionListHandle>(null);
ref={selectionListRef}
onPress={() => {
selectionListRef.current?.clearInputAfterSelect?.();
toggleOption(item);
}}
What do you think about this? cc @alitoshmatov
Looks good! @alitoshmatov could you please take a close look if I am missing anything
This does look much better solution. I think we should go with this solution. cc: @MonilBhavsar
Thanks for checking. Let's move forward!
π£ @alitoshmatov π An offer has been automatically sent to your Upwork account for the Reviewer role π Thanks for contributing to the Expensify app!
π£ @nkdengineer π An offer has been automatically sent to your Upwork account for the Contributor role π Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review π§βπ» Keep in mind: Code of Conduct | Contributing π
@alitoshmatov The PR is here.
watching PR - https://github.com/Expensify/App/pull/42336
watching PR - https://github.com/Expensify/App/pull/42336
PR https://github.com/Expensify/App/pull/42336 is merged.
Testing the steps in the OP again, I think this is still an issue.
@nkdengineer and @alitoshmatov can you check again?
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.66-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: @shawnborton Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1714064614847909
Action Performed:
Expected Result:
Search term clears and search input is focussed - details here- https://github.com/Expensify/App/issues/41049#issuecomment-2088154813
Actual Result:
The search input doesn't clear, so even after you select someone, you have no context in terms of how many other people were selected or who else is available to be selected
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/Expensify/App/assets/51066321/b07f6d8b-d763-48b0-8fe1-0660a70b2ab9
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @alexpensify