-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Selected category moves to the top when category list size is under 8 #37127
Conversation
@eVoloshchak Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@eVoloshchak Please reassign to @DylanDylann since he was the C+ of the original issue causing this regresison. |
@DylanDylann There's one small edge case when the list size change from < 8 to >= 8, the selected option moves to the top but the highlight does not: I tried reverting the changes in this PR and #35922 but that did not solve the problem. Seems like it was already there before thus out of scope of this PR. |
const enabledAndSelectedCategoriesIndex = enabledAndSelectedCategories.findIndex((category) => category.name === selectedOption.name); | ||
if (enabledAndSelectedCategoriesIndex !== -1) { | ||
enabledAndSelectedCategories.splice(enabledAndSelectedCategoriesIndex, 1, selectedOption); | ||
} |
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.
@tienifr as the person that originally worked on the solution above, I'll take the liberty to drop a comment here. There's an edge case where a deleted category that's currently selected won't show on the list. That's because the deleted category is present in selectedOptions
but not in sortedCategories
. That's why I originally had the unshift
line:
if (enabledAndSelectedCategoriesIndex === -1) {
enabledAndSelectedCategories.unshift(selectedOption);
} else {
enabledAndSelectedCategories.splice(enabledAndSelectedCategoriesIndex, 1, selectedOption);
}
The only thing is by doing the above, any deleted category will always be at the top of the list which even as an edge case I don't think we would want. As with the other bug you mentioned, this bug was already present and thus out of scope, but I wanted to drop a comment here so we don't forget about it. I'd be glad to tackle it if we decide opening up a new issue.
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.
I tested on production and verified that we always hide deleted category because it will not be returned from the backend, thus no data in Onyx. And in case this turns out to be an issue, I think it is out of scope and should be handled separately.
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.
This is staging with more than 8 categories. Right now if we drop to, say, 4 categories, the deleted category is still there, at the top. After merging this PR, it would no longer be there.
And in case this turns out to be an issue, I think it is out of scope and should be handled separately.
My thought as well, this issue was there before the original PR. I just wanted to drop say something so it's not forgotten.
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.
This is staging with more than 8 categories.
Original PR has already been deployed to staging so you will always see the selected catagory no matter it was deleted/disabled or not. We should test on production to verify the correct results before that PR.
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.
I understand that. And if you checkout master to the commit right before the original PR, the deleted category will NOT be there when there are less than 8 categories, but it WILL when there are more. It's an old bug that's been there already for quite a while. It's not related to this PR nor the original PR. My intention is to bring up a new bug I stumbled upon and by no means I'm implying your PR caused it nor that it should be fixed as part of this one.
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.
but it WILL when there are more
Oh thanks for that information, I wasn't aware of that. So let's see what @DylanDylann's point on this?
TL;DR Do we need to show the SELECTED but DELETED category in the list? On production, it's hidden when list size < 8 but shown otherwise and it's definitely a bug. If you think it is out of scope of this PR, please somehow report it.
@eVoloshchak please ignore this PR, It is a regression from another issue. So I will review it |
Pending confirmation in #36912 (comment). |
Closing as discussed here. Please comment in the issue if you believe partial payment would be required. |
Details
When category list length is under 8, selected category should remain its position in alphabetic order within the list. Otherwise, it moves to the top.
Fixed Issues
$ #36912
PROPOSAL:
Tests
Offline tests
NA
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.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 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