-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: use localeCompare to sort in mention list #45324
Conversation
Signed-off-by: dominictb <tb-dominic@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make utils and add unit test
on it now! |
@situchan done! |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.mp4Android: mWeb Chromemchrome.mp4iOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Desktopdesktop.mov |
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
waiting for @situchan's review. |
@dominictb please merge main |
done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dominictb @situchan please add screenshots/video for all platforms |
@dominictb also, QA Step is a bit confusing.
As a result, you should add:
|
@cead22 done! |
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
function getDisplayName(p: PersonalDetails) { | ||
const displayNameFromAccountID = ReportUtils.getDisplayNameForParticipant(p.accountID); | ||
if (!displayNameFromAccountID) { | ||
return p.login?.length ? p.login : ''; | ||
} | ||
return displayNameFromAccountID; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function getDisplayName(p: PersonalDetails) { | |
const displayNameFromAccountID = ReportUtils.getDisplayNameForParticipant(p.accountID); | |
if (!displayNameFromAccountID) { | |
return p.login?.length ? p.login : ''; | |
} | |
return displayNameFromAccountID; | |
} | |
function getDisplayName(details: PersonalDetails) { | |
const displayNameFromAccountID = ReportUtils.getDisplayNameForParticipant(details.accountID); | |
if (!displayNameFromAccountID) { | |
return details.login?.length ? details.login : ''; | |
} | |
return displayNameFromAccountID; | |
} |
* the comparison function used to determine which user will come first in the sorted list | ||
* generally, smaller weight means will come first, and if the weight is the same, we'll sort based on displayName/login and accountID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the comparison function used to determine which user will come first in the sorted list | |
* generally, smaller weight means will come first, and if the weight is the same, we'll sort based on displayName/login and accountID | |
* Comparison function to sort users. It compares weights, display names, and accountIDs in that order |
// first, we should sort by weight | ||
if (first.weight !== second.weight) { | ||
return first.weight - second.weight; | ||
} | ||
|
||
// next we sort by display name | ||
const displayNameLoginOrder = localeCompare(getDisplayName(first), getDisplayName(second)); | ||
if (displayNameLoginOrder !== 0) { | ||
return displayNameLoginOrder; | ||
} | ||
// then fallback on accountID as the final sorting criteria. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jsdoc already explains this, and this says what the code is doing, which is obvious from reading the code. Since these comments don't follow our style guide (should use capital letters on the first word), I suggest removing them
// first, we should sort by weight | |
if (first.weight !== second.weight) { | |
return first.weight - second.weight; | |
} | |
// next we sort by display name | |
const displayNameLoginOrder = localeCompare(getDisplayName(first), getDisplayName(second)); | |
if (displayNameLoginOrder !== 0) { | |
return displayNameLoginOrder; | |
} | |
// then fallback on accountID as the final sorting criteria. | |
if (first.weight !== second.weight) { | |
return first.weight - second.weight; | |
} | |
const displayNameLoginOrder = localeCompare(getDisplayName(first), getDisplayName(second)); | |
if (displayNameLoginOrder !== 0) { | |
return displayNameLoginOrder; | |
} |
}); | ||
}) as Array<PersonalDetails & {weight: number}>; | ||
|
||
// at this point we are sure that the details are not null, since empty user details have been filtered in the previous step |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// at this point we are sure that the details are not null, since empty user details have been filtered in the previous step | |
// At this point we are sure that the details are not null, since empty user details have been filtered in the previous step |
@cead22 updated. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/cead22 in version: 9.0.15-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.15-9 🚀
|
Details
Fixed Issues
$ #43845
PROPOSAL: #43845 (comment)
Tests
Pre-requisite: Create 4 account with name
águero
,Bronn
,Carol
,Daniel
.@
Verify that the order in the mention list is
here
,águero
,Bronn
,Carol
,Daniel
(or if you invite the above 4 accounts, should beaName
,B
,Bname
,Workspace member
)Offline tests
QA Steps
Pre-requisite: Create 4 account with name
águero
,Bronn
,Carol
,Daniel
(or any other equivalent names which highlight the alphabetical order). Or can invite the following account:natnael.expensify+idf6yd@gmail.com,
natnael.expensify+lajf088b@gmail.com,
natnael.expensify+ldjf66vd@gmail.com,
natnael.expensify+3@gmail.com
@
Verify that the order in the mention list is
here
,águero
,Bronn
,Carol
,Daniel
(or if you invite the above 4 accounts, should beaName
,B
,Bname
,Workspace member
)PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop