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

WS - Members - Avatars group on final screen moves to the left if admin invites more 8 users #22685

Closed
2 of 6 tasks
lanitochka17 opened this issue Jul 11, 2023 · 12 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 11, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Open and login with expensifail account to staging.new.expensify.com or Expensify App
  2. Go to existing or create new workspace
  3. Go to Workspace > Members
  4. Click / Tap 'Invite'
  5. Select more then 8 users
  6. Click 'Next'

Expected Result:

The avatar group on the final screen is always in the center

Actual Result:

The avatars group on final screen moves to the left if admin invites more 8 users
The shift to the left gets bigger with each user added

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.39.5

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

Bug6124175_WS-Invite-users-avatars-cut.mp4

Bug6124175_WS-Invite-users-avatars-cut

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 11, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 11, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@StevenKKC
Copy link
Contributor

StevenKKC commented Jul 11, 2023

Proposal

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

Avatars group on final screen moves to the left if admin invites more 8 users.

What is the root cause of that problem?

Avatar group's width is calculated as below.

if (props.icons.length > 4) {
const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
} else {
// one avatar width + overlaping avatar sizes + border space
width = oneAvatarSize.width + overlapSize * 2 * (props.icons.length - 1) + oneAvatarBorderWidth * (props.icons.length * 2);
}

// Slice the icons array into two rows
const firstRow = props.icons.slice(rowSize);
const secondRow = props.icons.slice(0, rowSize);

If have more than 8 avatar, length would be greater than props.maxAvatarsInRow (4).
So avatar group moves to the left.

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

Avatar group's width should be equal to or less than props.maxAvatarsInRow.
We can change code as below.

-   const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
+   const length = Math.min(avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length, props.maxAvatarsInRow);

What alternative solutions did you explore? (Optional)

None.

@DrLoopFall
Copy link
Contributor

There's also another issue #22632, connected to this, even though the issues are different, the root cause remains the same.
I've made a proposal there which would solve both issues, I'll also leave a proposal below just in case.

@DrLoopFall
Copy link
Contributor

Proposal

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

Workspace members avatars group on the final screen moves to the left if the admin invites more than 8 users

What is the root cause of that problem?

We are using left for positioning/shifting avatars, which causes it to use more space than required.

left: -(overlapSize * index),

left: -(oneAvatarSize.width * 2 + oneAvatarBorderWidth * 2),

Also, currently, we are calculating the width, as a workaround, which is also a part of the problem in this issue.

@stitesExpensify I think the width was set as a workaround for the issue described in my proposal (the 2nd issue)

We are using left for positioning/shifting avatars but the PressableWithoutFeedback itself is not shifted, which causes it to be clickable in both the original and shifted positions.

If we use margin-left instead, we can remove the width, which may prevent any future issues.

if (props.icons.length > 4) {
const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
} else {
// one avatar width + overlaping avatar sizes + border space
width = oneAvatarSize.width + overlapSize * 2 * (props.icons.length - 1) + oneAvatarBorderWidth * (props.icons.length * 2);
}

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

Use margin-left instead of left for positioning the avatar.

// in getHorizontalStackedAvatarStyle
- left: -(overlapSize * index)
+ marginLeft: index > 0 ? -overlapSize : 0

// in getHorizontalStackedOverlayAvatarStyle
- left: -(oneAvatarSize.width * 2 + oneAvatarBorderWidth * 2)
+ marginLeft: -(oneAvatarSize.width + oneAvatarBorderWidth * 2)

We should also need to remove the width, as we don't need it anymore, because this proposal also removes the need for the workaround as it fixes the issue in the root, and removing it may prevent future issues like this.

if (props.icons.length > 4) {
const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
} else {
// one avatar width + overlaping avatar sizes + border space
width = oneAvatarSize.width + overlapSize * 2 * (props.icons.length - 1) + oneAvatarBorderWidth * (props.icons.length * 2);
}

@melvin-bot
Copy link

melvin-bot bot commented Jul 14, 2023

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

@huzaifa-99
Copy link
Contributor

huzaifa-99 commented Jul 17, 2023

My proposal here fixes this issue, reposting for visibility

Proposal

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

We want workspace icons to be aligned to right.

What is the root cause of that problem?

We do a different kind of width calculation when there are more than 4 icons, but at a single time we only display 4 icons. The extra width moves the icons to left.

if (props.icons.length > 4) {
const length = avatarRows.length > 1 ? Math.max(avatarRows[0].length, avatarRows[1].length) : avatarRows[0].length;
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
} else {

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

We should update the width calculation here. Since we only display a max of 4 icons, we can remove the length calculation and use 4 directly (which comes from props.maxAvatarsInRow), and simplify this whole block with this condition

const length = Math.min(props.maxAvatarsInRow, props.icons.length)
width = oneAvatarSize.width + overlapSize * 2 * (length - 1) + oneAvatarBorderWidth * (length * 2);
image
image
image

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot
Copy link

melvin-bot bot commented Jul 18, 2023

@johncschuster 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@johncschuster
Copy link
Contributor

If the root cause will be fixed in another issue, does this issue need to remain open?

(I'm not sure, so I'm asking in Slack)

@melvin-bot melvin-bot bot removed the Overdue label Jul 18, 2023
@johncschuster
Copy link
Contributor

bumping my question above

@Santhosh-Sellavel
Copy link
Collaborator

@johncschuster Yeah can close this one in favor of #22632

@johncschuster
Copy link
Contributor

Thanks, @Santhosh-Sellavel!

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
Projects
None yet
Development

No branches or pull requests

6 participants