Skip to content

[$1000] Web - On copy paste on workspace invite message page, app pastes text on compose box #23184

Closed

Description

@kbecciv

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. Open the app
  2. Open settings
  3. Open workspaces
  4. Open any workspace
  5. Open members
  6. Reload the page
  7. Remove any user
  8. Click on invite and select any issue
  9. Click Next
  10. On invite message page, copy the current text and try to paste same text after it, observe that text is pasted in compose box behind

Expected Result:

App should paste text in invite message field if we copy and paste text while invite message field is in focus

Actual Result:

App pastes the text in compose box when we reload on members page, remove 1 member and invite any other and reach invite message paste

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.42-18
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
Notes/Photos/Videos: Any additional supporting documentation

invite.message.paste.in.compose.mp4
Recording.3757.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1689703579147449

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0105c6892023aa08e8
  • Upwork Job ID: 1683525862926856192
  • 2023-07-24
  • Automatic offers:
    • dhanashree-sawant | Reporter | 25841637

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 19, 2023
  2. melvin-bot commented on Jul 19, 2023

    @melvin-bot

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

  3. melvin-bot commented on Jul 19, 2023

    @melvin-bot

    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
  4. samh-nl commented on Jul 19, 2023

    @samh-nl
    Contributor

    Proposal

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

    Copy-paste on the workspace invite page leads to the text being pasted in the compose box.

    What is the root cause of that problem?

    When pasting to the composer, it checks checkComposerVisibility to ensure that the composer is visible:

    checkComposerVisibility() {
    const isComposerCoveredUp = EmojiPickerActions.isEmojiPickerVisible() || this.state.isMenuVisible || this.props.modal.isVisible;
    return !isComposerCoveredUp;
    }

    Normally, when a modal is open, this function blocks due to the this.props.modal.isVisible inside the if-statement.

    However, when deleting a member in a workspace, you are presented with a confirmation modal asking you whether you're sure. When this modal closes, this.props.modal.isVisible becomes false, therefore checkComposerVisibility returns true. This leads to the incorrect pasting behavior.

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

    When closing a modal, we should not set modal.isVisible to false if there are other modals opened.

    What alternative solutions did you explore? (Optional)

    Option 1. For ensuring that the composer is visible, we can check that the active route is NAVIGATORS.CENTRAL_PANE_NAVIGATOR, instead of checking whether a modal is active or not.

    Option 2. When opening a modal, we determine the value of modal.isVisible. Subsequently, when closing the modal, we only set it to false if it was false initially. If a modal was already opened, we will not change its value.

    Option 3. We could set the shouldSetModalVisibility prop to false in the ConfirmModal when deleting the member, however this may not be an elegant solution to the problem as this issue may also be present in other modals. We would need to identify where else a similar problem may arise.

  5. yh-0218 commented on Jul 19, 2023

    @yh-0218
    Contributor

    Proposal

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

    Copy-paste on the workspace invite page leads to the text being pasted in the compose box.

    What is the root cause of that problem?

    After reload, composer gets paste event and check value of checkComposerVisibility function.

    checkComposerVisibility() {
    const isComposerCoveredUp = EmojiPickerActions.isEmojiPickerVisible() || this.state.isMenuVisible || this.props.modal.isVisible;
    return !isComposerCoveredUp;
    }

    when closing remove member Dialog, this.propos.modal.isVisible becomes to false.
    so composer gets the incorrect paste.

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

    When closing Modal, we should not set ONYXKEYS.MODAL value.

    <ConfirmModal
    danger
    title={props.translate('workspace.people.removeMembersTitle')}
    isVisible={removeMembersConfirmModalVisible}
    onConfirm={removeUsers}
    onCancel={() => setRemoveMembersConfirmModalVisible(false)}
    prompt={props.translate('workspace.people.removeMembersPrompt')}
    confirmText={props.translate('common.remove')}
    cancelText={props.translate('common.cancel')}
    />

    we can add this ConfirmModal of WorkspaceMembersPage

    shouldSetModalVisibility={false}
    

    What alternative solutions did you explore? (Optional)

  6. makiour commented on Jul 19, 2023

    @makiour
    Contributor

    Proposal

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

    The issue here is that the paste command is not working when trying to paste into invite message after deleting a user.

    Investigation
    After I looked into the error, I found that a paste issue is occuring also when we try to paste in the edited comment as it is a composer component same as the main chat composer.
    When we try to paste into an edited comment, it also pastes into the main composer of the report open. Here is a video illustrating the issue.

    bugPasting.webm

    Thus, the root cause should be fixing the whole pasting mechanism as it occurs in multiple instances of components.

    What is the root cause of that problem?

    The first thing I did is investigating the paste function, and I found that there was a global paste event listener which is always called and triggered when the component mount here:

    // We need to add paste listener manually as well as navigation focus event is not triggered on component mount
    document.addEventListener('paste', this.handlePaste);
    }

    And will unmount here:

    document.removeEventListener('paste', this.handlePaste);

    My first thought is that a general paste listener is not needed as we have handlePaste that will do the job, however, the issue here is if we delete the global pasting listener, this will not allow attachment or HTML pasting and they are handled differently.

    The root cause, then, is that we are making the listener global for the entire HTML document, which affects all elements/components of the page. Thus, we need to handle it specifically for the input we are dealing with:

    --> We need to use the textInput element istead of document where the listener then will be associated with only to the specific input!

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

    We need to change componentDidMount line:

    document.addEventListener('paste', this.handlePaste);

    to

    this.textInput.addEventListener('paste', this.handlePaste);

    and componentWillUnmount line:

    document.removeEventListener('paste', this.handlePaste);

    To

    this.textInput.removeEventListener('paste', this.handlePaste);

    What alternative solutions did you explore? (Optional)

    N/A

  7. dukenv0307 commented on Jul 20, 2023

    @dukenv0307
    Contributor

    it seems that this PR causes regression #21583

  8. johncschuster commented on Jul 21, 2023

    @johncschuster
    Contributor

    Heads up, @robertKozik

  9. ginsuma commented on Jul 22, 2023

    @ginsuma
    Contributor

    Proposal

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

    Web - On copy paste on workspace invite message page, app pastes text on compose box.

    What is the root cause of that problem?

    With normal flow, paste event will be removed when report page blurred by here. But when we use direct link, it won't happen and paste event still listen by here.

    In handlePaste, we check checkComposerVisibility with the condition of modal.isVisible here. When we cancel ConfirmModal, it become false then checkComposerVisibility is true => not early return to block paste event to main composer.

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

    I think we shouldn't rely on modal key to focus or set value for composer.
    We will do it when the active route is CentralPaneNavigator.
    Creating a function in Navigation like below:

    function isCPNRoute() {
        const rootState = navigationRef.getRootState();
        const lastRoute = _.last(rootState.routes);
        return lastRoute.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR;
    }

    Then change checkComposerVisibility to:

    checkComposerVisibility() {
            const isComposerCoveredUp = !Navigation.isCPNRoute() || EmojiPickerActions.isEmojiPickerVisible() || this.state.isMenuVisible
            return !isComposerCoveredUp;
    }

    What alternative solutions did you explore? (Optional)

    We can use isCPNRoute to other issues about focusing main composer here.

  10. robertKozik commented on Jul 24, 2023

    @robertKozik
    Contributor

    thanks @johncschuster for mentioning. Looking into it as indeed it's regression

  11. 30 remaining items

  12. melvin-bot commented on Aug 2, 2023

    @melvin-bot

    @johncschuster @parasharrajat @Santhosh-Sellavel 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!

  13. johncschuster commented on Aug 2, 2023

    @johncschuster
    Contributor

    It seems the issue is no longer reproducible. Holding.

  14. Santhosh-Sellavel commented on Aug 7, 2023

    @Santhosh-Sellavel
    Collaborator

    Just on hold, for now, discussion in Slack here

  15. johncschuster commented on Aug 7, 2023

    @johncschuster
    Contributor

    Thanks for the heads up, @Santhosh-Sellavel!

  16. melvin-bot commented on Aug 9, 2023

    @melvin-bot

    @johncschuster @parasharrajat @Santhosh-Sellavel this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

  17. Santhosh-Sellavel commented on Aug 9, 2023

    @Santhosh-Sellavel
    Collaborator

    @johncschuster We decided not to revert the PR, so we can close this one and just issue reporting bonus here. As this one is already fixed.

  18. johncschuster commented on Aug 14, 2023

    @johncschuster
    Contributor

    Payment has been issued to the bug reporter (@dhanashree-sawant). Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions