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

[HOLD for payment 2023-03-13] [$4000] LHN - Workspace badge is not fully visible/missing for some Room chats #14491

Closed
6 tasks done
kbecciv opened this issue Jan 23, 2023 · 134 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff

Comments

@kbecciv
Copy link

kbecciv commented Jan 23, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to staging.new.expensify.com
  2. Log i with expensifail account (applausetester+0901abb@applause.expensifail.com/Feya8Katya)
  3. Plus on Fub menu
  4. Select New Room
  5. Put 00--00--00--00--00--00--00--00--00 on room name
  6. Select WS ( PR testing)
  7. Save Room
  8. Go back to LHN

Expected Result:

WS badge is fully visible and present for all chats

Actual Result:

Workspace badge is not fully visible/missing for some Room chats

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.2.58.2

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

Expensify/Expensify Issue URL:

Issue reported by: Applause - internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016ac522930fd1c9d2
  • Upwork Job ID: 1620286474913542144
  • Last Price Increase: 2023-02-14
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jan 23, 2023

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

@melvin-bot melvin-bot bot locked and limited conversation to collaborators Jan 23, 2023
@JmillsExpensify
Copy link

Wow this one is pretty wild. I need another day to circle back and close the loop on this one.

@JmillsExpensify
Copy link

Screenshot 2023-01-26 at 17 02 33

Alright, sorry for the delay! I'm able to reproduce this one.

@JmillsExpensify
Copy link

That said, @shawnborton it'd be good to get your take on this one. Like on the one hand, I'm not sure if we should optimize for showing the workspace badge in this case, because the the room name is ultimately more important. Overall, I'm not convinced this is a bug. I'm going to hold off triaging it until we get another set of eyes.

@shawnborton
Copy link
Contributor

I think this is such an edge case.

That being said, one easy way to fix this would be to give the badge a min-width so that in the very least, you can always see at least 3-4 characters of the badge as well.

I think ideally the room name and badge would be truncated via ellipsis, I could have sworn that's how it was implemented.

@bernhardoj do you have any thoughts on this? Since you worked on this PR here.

@shawnborton
Copy link
Contributor

@bernhardoj can't comment on this issue, but sent me this on Slack:

Hi, I see you mentioned me on this issue, but I can't comment on it, so I chat you here 😅.

I also initially thought that we already truncate for both chat name and the pill's text. However, after looking at the code again, apparently we didn't do that.

The chat name has flex shrink 0 set to it which means the text will never be shrunk and will take the whole width. We do that to address this issue #11799 (comment)

Even before the text pill feature added, the flex shrink 0 already being used, but only on compact (focus) mode. Now, we apply the flex shrink 0 to the chat name no matter what the mode is because now the text pill always sits next to the chat name.

So I say we open this up as a bug and allow @bernhardoj to submit a proposal to fix since he originally worked on this. I don't think this is a regression because it's working as expected from the original PR, but this was an oversight in our testing.

@melvin-bot melvin-bot bot added the Overdue label Jan 30, 2023
@JmillsExpensify JmillsExpensify added the External Added to denote the issue can be worked on by a contributor label Jan 31, 2023
@melvin-bot melvin-bot bot unlocked this conversation Jan 31, 2023
@melvin-bot melvin-bot bot changed the title LHN - Workspace badge is not fully visible/missing for some Room chats [$1000] LHN - Workspace badge is not fully visible/missing for some Room chats Jan 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jan 31, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016ac522930fd1c9d2

@melvin-bot
Copy link

melvin-bot bot commented Jan 31, 2023

Current assignee @JmillsExpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jan 31, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 31, 2023
@JmillsExpensify
Copy link

Cool, agreed. Pretty significant edge case. Opening up the issue for now.

@melvin-bot
Copy link

melvin-bot bot commented Jan 31, 2023

Triggered auto assignment to @grgia (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Overdue label Jan 31, 2023
@daniel-gig
Copy link

I think this is such an edge case, too.

That being said, one easy way to fix this would be to give the badge a min-width so that in the very least, you can always see at least 3-4 characters of the badge as well.

And there should be one thing to do.

I can totally settle this issue in a day if assigned.
Thanks.

@daraksha-dk
Copy link
Contributor

daraksha-dk commented Jan 31, 2023

Proposal

The room name isn't shrinking because we're using flex-shrink: 0 here

flexShrink: 0,

We can fix this either by removing flex-shrink: 0 from above OR we can pass styles.flexShrink1 below (This can be done conditionally since we're using TextPill component only when optionItem.isChatRoom is true)

const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, styles.optionDisplayNameCompact, ...textUnreadStyle], props.style);

@daraksha-dk

This comment was marked as outdated.

@daraksha-dk

This comment was marked as outdated.

@bernhardoj
Copy link
Contributor

bernhardoj commented Jan 31, 2023

Proposal

I can't find a "pure css" way to solve this issue, so I need to use the help of onLayout. We can't simply set the minWidth because flex shrink 0 is set to the display name component. If we set the flex shrink to a bigger value, this issue will happen again when the workspace name is very long, could even make the display name width very small when the display name is short and the workspace name is very long. I am suggesting keeping the flex shrink to 0 to let the display name grow as wide as it can, but with respect to the text pill width (with the help of onLayout).

We will set the max width of the display name to 75% of the total width IF the text pill width >= 25% of the total width. Else, the max width will be (total width - text pill width). I move the whole logic to a new component called OptionRowTitle.

import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';
import * as StyleUtils from '../../styles/StyleUtils';
import DisplayNames from '../DisplayNames';
import TextPill from '../TextPill';

const propTypes = {
    /** Option row data */
    optionItem: PropTypes.object.isRequired,

    displayNameStyle: PropTypes.arrayOf(PropTypes.object),

    textPillStyle: PropTypes.arrayOf(PropTypes.object),
}

const defaultProps = {
    displayNameStyle: [],
    textPillStyle: [],
}

class OptionRowTitle extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            width: 0,
            textPillWidth: 0,
        }
    }

    render() {
        let displayNameMaxWidth = '100%';

        if (this.props.optionItem.isChatRoom) {
            displayNameMaxWidth = this.state.width > 0 && this.state.textPillWidth > 0
                ? Math.max(this.state.width * 75/100, this.state.width - this.state.textPillWidth)
                : '75%';
        }

        return (
            <View
                onLayout={e => this.setState({width: e.nativeEvent.layout.width})} 
                style={[styles.flexRow, styles.alignItemsCenter, styles.mw100, styles.overflowHidden]}
            >
                <DisplayNames
                    accessibilityLabel="Chat user display names"
                    fullTitle={this.props.optionItem.text}
                    displayNamesWithTooltips={this.props.optionItem.displayNamesWithTooltips}
                    tooltipEnabled
                    numberOfLines={1}
                    textStyles={[
                        ...this.props.displayNameStyle,
                        StyleUtils.getMaxWidthStyle(displayNameMaxWidth),
                    ]}
                    shouldUseFullTitle={this.props.optionItem.isChatRoom || this.props.optionItem.isPolicyExpenseChat}
                />
                {this.props.optionItem.isChatRoom && (
                    <TextPill
                        style={this.props.textPillStyle}
                        accessibilityLabel="Workspace name"
                        text={this.props.optionItem.subtitle}
                        onLayout={e => this.setState({textPillWidth: e.nativeEvent.layout.width + 4})}
                    />
                )}
            </View>
        )
    }
}

OptionRowTitle.propTypes = propTypes;
OptionRowTitle.defaultProps = defaultProps;

export default OptionRowTitle;

The initial max width value is 100% in case the text pill will not be shown. We wait for the onLayout completes before doing the calculation. While waiting the completion, we need to set the max width to 75% to let the text pill rendered at least 25% wide. The value of 4 on the text pill width is the margin left of the text pill.

diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js
index e64ed774b8..be998c6454 100644
--- a/src/components/LHNOptionsList/OptionRowLHN.js
+++ b/src/components/LHNOptionsList/OptionRowLHN.js
@@ -12,7 +12,6 @@ import Icon from '../Icon';
 import * as Expensicons from '../Icon/Expensicons';
 import MultipleAvatars from '../MultipleAvatars';
 import Hoverable from '../Hoverable';
-import DisplayNames from '../DisplayNames';
 import IOUBadge from '../IOUBadge';
 import colors from '../../styles/colors';
 import withLocalize, {withLocalizePropTypes} from '../withLocalize';
@@ -22,8 +21,8 @@ import CONST from '../../CONST';
 import variables from '../../styles/variables';
 import themeColors from '../../styles/themes/default';
 import SidebarUtils from '../../libs/SidebarUtils';
-import TextPill from '../TextPill';
 import OfflineWithFeedback from '../OfflineWithFeedback';
+import OptionRowTitle from './OptionRowTitle';
 
 const propTypes = {
     /** Style for hovered state */
@@ -67,7 +66,7 @@ const OptionRowLHN = (props) => {
         : styles.sidebarLinkText;
     const textUnreadStyle = optionItem.isUnread
         ? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
-    const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, styles.optionDisplayNameCompact, ...textUnreadStyle], props.style);
+    const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, ...textUnreadStyle], props.style);
     const textPillStyle = props.isFocused
         ? [styles.ml1, StyleUtils.getBackgroundColorWithOpacityStyle(themeColors.icon, 0.5)]
         : [styles.ml1];
@@ -164,24 +163,12 @@ const OptionRowLHN = (props) => {
                                 )
                                 }
                                 <View style={contentContainerStyles}>
-                                    <View style={[styles.flexRow, styles.alignItemsCenter, styles.mw100, styles.overflowHidden]}>
-                                        <DisplayNames
-                                            accessibilityLabel="Chat user display names"
-                                            fullTitle={optionItem.text}
-                                            displayNamesWithTooltips={optionItem.displayNamesWithTooltips}
-                                            tooltipEnabled
-                                            numberOfLines={1}
-                                            textStyles={displayNameStyle}
-                                            shouldUseFullTitle={optionItem.isChatRoom || optionItem.isPolicyExpenseChat}
-                                        />
-                                        {optionItem.isChatRoom && (
-                                            <TextPill
-                                                style={textPillStyle}
-                                                accessibilityLabel="Workspace name"
-                                                text={optionItem.subtitle}
-                                            />
-                                        )}
-                                    </View>
+                                    <OptionRowTitle
+                                        optionItem={optionItem}
+                                        displayNameStyle={displayNameStyle}
+                                        textPillStyle={textPillStyle}
+                                        key={props.viewMode}
+                                    />
                                     {optionItem.alternateText ? (
                                         <Text
                                             style={alternateTextStyle}
diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js
index 40bf28b37b..aa642c50cc 100644
--- a/src/styles/StyleUtils.js
+++ b/src/styles/StyleUtils.js
@@ -182,6 +182,16 @@ function getWidthStyle(width) {
     };
 }
 
+/**
+ * @param {String|number} maxWidth 
+ * @returns 
+ */
+function getMaxWidthStyle(maxWidth) {
+    return {
+        maxWidth,
+    };
+}
+
 /**
  * Returns a style with backgroundColor and borderColor set to the same color
  *
@@ -670,6 +680,7 @@ export {
     getZoomCursorStyle,
     getZoomSizingStyle,
     getWidthStyle,
+    getMaxWidthStyle,
     getBackgroundAndBorderStyle,
     getBackgroundColorStyle,
     getBackgroundColorWithOpacityStyle,
diff --git a/src/styles/styles.js b/src/styles/styles.js
index 4b1d1982ae..eaae8bed7c 100644
--- a/src/styles/styles.js
+++ b/src/styles/styles.js
@@ -1188,14 +1188,8 @@ const styles = {
         fontFamily: fontFamily.EXP_NEUE,
         height: variables.alternateTextHeight,
         lineHeight: variables.lineHeightXLarge,
-        ...whiteSpace.noWrap,
-    },
-
-    optionDisplayNameCompact: {
-        minWidth: 'auto',
-        flexBasis: 'auto',
-        flexGrow: 0,
         flexShrink: 0,
+        ...whiteSpace.noWrap,
     },
 
     displayNameTooltipEllipsis: {

I remove the optionDisplayNameCompact style as no other component use it. I also add key props to the OptionRowTitle, so when the props changed, OptionRowTitle will be re-rendered with all the state reset to the initial state value. This is useful when we are changing the view mode (most recent/focus).

We can additionally set the OptionRowTitle opacity to 0 while waiting for the calculation to finish, and set it back to 1 after it finish

I don't have access to Room so I change the display name and text pill state directly from the code, just for testing

Result
Normal Mode
image

Compact Mode
image

@shawnborton
Copy link
Contributor

Ah interesting, looks like @daraksha-dk was able to find a "CSS-only" approach to this?

@bernhardoj
Copy link
Contributor

If the flex shrink is removed or set to 1, this will happen when the display name text is short and the workspace name is long.
image

Basically, the same issue with this #11799 (comment). That's why we decided to use the flex shrink 0.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Mar 6, 2023
@melvin-bot melvin-bot bot changed the title [$4000] LHN - Workspace badge is not fully visible/missing for some Room chats [HOLD for payment 2023-03-13] [$4000] LHN - Workspace badge is not fully visible/missing for some Room chats Mar 6, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 6, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@MelvinBot
Copy link

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.2.78-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-03-13. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

MelvinBot commented Mar 6, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@aimane-chnaif / @grgia] The PR that introduced the bug has been identified. Link to the PR: N/A - bug was initial design choice
  • [@aimane-chnaif / @grgia] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
  • [@aimane-chnaif / @grgia] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
  • [@situchan] Propose regression test steps to ensure the same bug will not reach production again.
  • [@JmillsExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Mar 12, 2023
@grgia
Copy link
Contributor

grgia commented Mar 15, 2023

For the BZ checklist, I don't think this is as much of a bug caused than an edge case we didn't account for. Perhaps we need to encourage thinking about edge cases in the design process for these features. i.e how will this look with long/short text, how will this shrink/grow, etc. What do you think @JmillsExpensify?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 15, 2023
@grgia
Copy link
Contributor

grgia commented Mar 20, 2023

Where are we at on payments for this issue? @JmillsExpensify

@melvin-bot melvin-bot bot removed the Overdue label Mar 20, 2023
@aimane-chnaif
Copy link
Contributor

I think everyone was busy at ECX last week. Hope BZ checklist and payment would be sorted this week.
Btw, @grgia can you please confirm PR merge timeline so @JmillsExpensify knows?

@melvin-bot melvin-bot bot added the Overdue label Mar 22, 2023
@grgia
Copy link
Contributor

grgia commented Mar 22, 2023

Timeline:
PR posted Feb 24
I posted initial approve Feb 24
@aimane-chnaif also posted PR checklist Feb 24
PR was merged Feb 27 due to a known failing Jest Test unrelated to PR

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Mar 22, 2023
@shawnborton
Copy link
Contributor

Not overdue

@melvin-bot melvin-bot bot removed the Overdue label Mar 27, 2023
@JmillsExpensify
Copy link

Sorry ya'll just coming back to this while all the travel and OOO.

Ok so in light of the post above, this issue is also eligible for the urgency bonus. Payments would be as follows:

  • Contributor: @situchan $3,000 (incl. 50% urgency bonus)
  • Contributor+: @aimane-chnaif $3,000 (incl. 50% urgency bonus)

Upwork job is here: https://www.upwork.com/jobs/~016b936b9b835a55e8. I've invited both contributors to the job, and the bonus will be paid out when the payment is processed.

That said, @situchan can you confirm where the suggested regression test is? It's checked off above but I'm not clear where you've posted it and we've agreed that it's appropriate.

@situchan
Copy link
Contributor

Sorry I thought it won't require regression step based on #14491 (comment).

Regression Test Proposal

  1. Login with any account
  2. Create new workspace if not exists
  3. Update workspace name to "PR testing"
  4. Go to Create new room page
  5. Put "00--00--00--00--00--00--00--00--00" on room name
  6. Select workspace - "PR testing"
  7. Save room and go back to LHN
  8. Verify that workspace (PR testing) badge is fully visible on "00--00--00--00--00--00--00--00--00" room

Do we agree 👍 or 👎

@aimane-chnaif
Copy link
Contributor

@JmillsExpensify upwork says "This offer is not available anymore"

@JmillsExpensify
Copy link

@aimane-chnaif ah Upwork oddities sorry about that. I just sent you a new contract for this Upwork job: https://www.upwork.com/jobs/~01583e015bbae3a6a4.

In other news, @situchan has been compensated and the contract is closed via Upwork. Thank you for the testing steps!

@aimane-chnaif
Copy link
Contributor

@JmillsExpensify accepted, thanks!

@JmillsExpensify
Copy link

All paid out! Regression testing steps are also linked above, so I think we're finally good to close this one out now. 🙌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff
Projects
None yet
Development

No branches or pull requests