Skip to content

[Due for payment 2025-04-14] [$250] Search - Pasting long text removes left padding & cursor focus is missing #58214

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

Closed
2 of 8 tasks
vincdargento opened this issue Mar 11, 2025 · 24 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 External Added to denote the issue can be worked on by a contributor

Comments

@vincdargento
Copy link

vincdargento commented Mar 11, 2025

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


Version Number: V9.1.11-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13
App Component: Search

Action Performed:

  1. Go to https://staging.new.expensify.com/home
  2. Tap the Search icon at the top
  3. Paste a short text into the search input
  4. Observe that the text has proper left padding, and the focus is on the cursor
  5. Remove the text
  6. Paste a long text into the search input

Expected Result:

The left padding should be consistent for both short and long pasted text.

After pasting long text, the focus should remain on the cursor.

Actual Result:

Pasting short text maintains proper left padding and keeps focus on the cursor.

Pasting long text removes left padding, making the text stick to the left margin.

Cursor focus is missing, requiring the user to scroll to bring it into view.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021899895633486475589
  • Upwork Job ID: 1899895633486475589
  • Last Price Increase: 2025-03-12
  • Automatic offers:
    • thelullabyy | Contributor | 106609870
Issue OwnerCurrent Issue Owner: @mananjadhav
@vincdargento vincdargento added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 11, 2025
Copy link

melvin-bot bot commented Mar 11, 2025

Triggered auto assignment to @isabelastisser (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Mar 11, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-11 13:47:54 UTC.

Proposal

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

Pasting long text removes left padding & cursor focus is missing

What is the root cause of that problem?

We apply styles.pl3 on inputStyle instead of textInputContainerStyles

and don't apply any padding right on textInputContainerStyles

textInputContainerStyles={[styles.borderNone, styles.pb0]}
inputStyle={[inputWidth, styles.pl3, {lineHeight: undefined}]}

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

Apply both padding left and right (padding horizontal) on textInputContainerStyles

and remove styles.pl3 from inputStyle

                        textInputContainerStyles={[styles.borderNone, styles.pb0, styles.ph3]}
                        inputStyle={[inputWidth, {lineHeight: undefined}]}

Additionally, if we want to address the cursor focus issue, we can use InputUtils.scrollToRight to scroll to the right whenever the cursor is at the end of the input text

    const [cursorSelection, setCursorSelection] = useState<{start: number; end: number}>({start: 0, end: 0});
    const handleSelectionChange = (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
        setCursorSelection(e.nativeEvent.selection);
    };

    useEffect(() => {
        if (ref && typeof ref !== 'function' && ref.current) {
            const input = ref.current as HTMLInputElement;
            if (cursorSelection.end === value.length) {
                scrollToRight(input);
            }
        }
    }, [value, cursorSelection, ref]);

and we should add onSelectionChange={handleSelectionChange} to the text input as well

                    <TextInput
                        ...
                        textInputContainerStyles={[styles.borderNone, styles.pb0, styles.ph3]}
                        inputStyle={[inputWidth, {lineHeight: undefined}]}
                        ...
                        onSelectionChange={handleSelectionChange}
                    />

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

None

What alternative solutions did you explore? (Optional)

New-Expensify.mp4

@thelullabyy
Copy link
Contributor

Proposal

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

Pasting short text maintains proper left padding and keeps focus on the cursor.

What is the root cause of that problem?

When text is pasted into the InputComponent, the paste callback from useHtmlPaste is executed.

const paste = useCallback(
(text: string) => {
try {
const textInputHTMLElement = textInputRef.current as HTMLElement;
if (textInputHTMLElement?.hasAttribute('contenteditable')) {
insertAtCaret(textInputHTMLElement, text, maxLength);
} else {
const htmlInput = textInputRef.current as unknown as HTMLInputElement;
const availableLength = maxLength - (htmlInput.value?.length ?? 0);
htmlInput.setRangeText(text.slice(0, availableLength));
}

Copied content is added to the text field only at the position where the cursor is currently located without automatically scrolling to the new cursor position.

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

Add this logic to calculate current position of the cursor and auto scroll input that position.

requestAnimationFrame(() => {
                    const selection = window.getSelection();
                    if (selection && selection.rangeCount > 0) {
                        const range = selection.getRangeAt(0);
                        const caretRect = range.getBoundingClientRect();
                        const inputRect = textInputHTMLElement.getBoundingClientRect();

                        // Calculate position need to scroll to
                        const scrollLeft = Math.max(0, 
                            caretRect.left - inputRect.left + textInputHTMLElement.scrollLeft - textInputHTMLElement.clientWidth / 2
                        );
                        const scrollTop = Math.max(0, 
                            caretRect.top - inputRect.top + textInputHTMLElement.scrollTop - textInputHTMLElement.clientHeight / 2
                        );

                        // Auto scroll to the position of cursor
                        textInputHTMLElement.scrollLeft = scrollLeft;
                        textInputHTMLElement.scrollTop = scrollTop;
                    }
                });

This solution not only solve the problem of the paste action with Input Search on this screen but also in all other screen which use InputComponent

With the left padding we've already have a PR here Text in search input, bounces with every letter added to the search to set opacity of the loading so we don't need add more padding and when we autoscroll with above logic, padding left will be correct

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@isabelastisser isabelastisser added External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors labels Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

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

@melvin-bot melvin-bot bot changed the title Search - Pasting long text removes left padding & cursor focus is missing [$250] Search - Pasting long text removes left padding & cursor focus is missing Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

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

@isabelastisser
Copy link
Contributor

Hi @mananjadhav, can you please review the proposals above? Thanks!

@mananjadhav
Copy link
Collaborator

I think we have similar solution of adding scrollToRight during the search. @nyomanjyotisa's proposal looks better to me.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Mar 13, 2025

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

@thelullabyy
Copy link
Contributor

@mananjadhav Can you help me explain why my proposal is not good? I think this is a global issue and needs to be addressed at all inputs.

Screen.Recording.2025-03-13.at.17.34.29.mov

Copy link

melvin-bot bot commented Mar 18, 2025

@mananjadhav Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Mar 18, 2025
@isabelastisser
Copy link
Contributor

@mananjadhav, can you please follow up on the question? I will DM you for visibility. thanks!

@mananjadhav
Copy link
Collaborator

It’s waiting for review from @marcochavezf.

@marcochavezf what do you think of the comment by #58214 (comment). I did a basic test of their proposal and it seems to work. But I haven’t stress tested.

Meanwhile the earlier selected proposal solves it at one place.

Let me know your thoughts.

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2025
@marcochavezf
Copy link
Contributor

Oh, interesting. I'm inclined toward the solution that fixes it everywhere; otherwise, we might end up solving the issue again in other cases. Let's assign @thelullabyy, I think we can work on the edge cases (if any) in the PR 🚀

@melvin-bot melvin-bot bot added the Overdue label Mar 21, 2025
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 21, 2025
Copy link

melvin-bot bot commented Mar 21, 2025

📣 @thelullabyy 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot removed the Overdue label Mar 21, 2025
Copy link

melvin-bot bot commented Mar 24, 2025

@mananjadhav Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Mar 24, 2025
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Overdue labels Mar 24, 2025
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Apr 7, 2025
@melvin-bot melvin-bot bot changed the title [$250] Search - Pasting long text removes left padding & cursor focus is missing [Due for payment 2025-04-14] [$250] Search - Pasting long text removes left padding & cursor focus is missing Apr 7, 2025
Copy link

melvin-bot bot commented Apr 7, 2025

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 7, 2025
Copy link

melvin-bot bot commented Apr 7, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.23-7 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 2025-04-14. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Apr 7, 2025

@mananjadhav @isabelastisser @mananjadhav The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 14, 2025
@isabelastisser
Copy link
Contributor

isabelastisser commented Apr 15, 2025

BugZero Checklist:

Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • @mananjadhav 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:

  • @mananjadhav If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:

  • @mananjadhav If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

Test:

Do we agree 👍 or 👎

@isabelastisser
Copy link
Contributor

isabelastisser commented Apr 15, 2025

Payment summary:

@mananjadhav requires payment through NewDot Manual Request. $250 for C+ review
@thelullabyy paid in Upwork automatic offer (Contributor)$250 for proposal

@isabelastisser
Copy link
Contributor

@mananjadhav, please complete the BZ checklist. Thanks!

@mananjadhav
Copy link
Collaborator

mananjadhav commented Apr 19, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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: Couldn't pinpoint an exact offending PR. This was a problem for all the inputs on a specific platform.

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: NA

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

I think it makes sense to add the regression test as it relates to a common component.

Regression Test Proposal

Test:

  1. Open Ap
  2. Tap the Search icon at the top
  3. Paste a short text into the search input
  4. Observe that the text has proper left padding, and the focus is on the cursor
  5. Remove the text
  6. Paste a long text into the search input
  7. Verify the focusing cursor remains visible at the end of the pasted text and the left padding is consistent for both short and long pasted text.

Do we agree 👍 or 👎

@isabelastisser ^

@garrettmknight
Copy link
Contributor

$250 approved for @mananjadhav

@melvin-bot melvin-bot bot added the Overdue label Apr 22, 2025
@isabelastisser
Copy link
Contributor

All set!

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 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

7 participants