Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.52k stars 2.87k forks source link

[$250] Android - Compose Box - Composer not expanded when adding emojis until reaching second line #51287

Open lanitochka17 opened 2 weeks ago

lanitochka17 commented 2 weeks ago

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


Version Number: 9.0.52-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5113856&group_by=cases:section_id&group_order=asc&group_id=306201 Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the Expensify app
  2. Open any chat
  3. On compose box, add several emojis until reaching a second line
  4. Verify the compose box is expanded and all the message is visible

Expected Result:

When the message with emojis reaches a second line, the compose box should expand to make all the message visible

Actual Result:

When adding several emojis and reaching a second line, the compose box is not expanded and only the second line is visible

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/58cde8f7-6a96-49a6-b213-eb6c74a2ce1c

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021851362613036850059
  • Upwork Job ID: 1851362613036850059
  • Last Price Increase: 2024-10-29
  • Automatic offers:
    • DylanDylann | Reviewer | 104755710
    • QichenZhu | Contributor | 104755712
Issue OwnerCurrent Issue Owner: @DylanDylann
melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @anmurali (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.

lanitochka17 commented 2 weeks ago

@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

melvin-bot[bot] commented 1 week ago

@anmurali Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

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

shahinyan11 commented 6 days ago

Proposal

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

Android - Compose Box - Composer not expanded when adding emojis until reaching second line

What is the root cause of that problem?

We have set height: 0 here but currently the input height does not increase when adding emoji and reaching the second line. It is android's behavior

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

  1. Add new state in Composer component
    const [inputContentHeight, setInputContentHeight] = useState<number | undefined>();
  2. Update above state in onContentSizeChange
    onContentSizeChange={(e) => {
    setInputContentHeight(e?.nativeEvent?.contentSize?.height)
    ....
    }
  3. Update composerStyle to bellow
    const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID
    const composerStyle = useMemo(() => StyleSheet.flatten([
    style, textContainsOnlyEmojis ? styles.onlyEmojisTextLineHeight : {},
    isAndroidNative ? {height: inputContentHeight} : undefined
    ]), [style, textContainsOnlyEmojis, styles, inputContentHeight]);

    What alternative solutions did you explore? (Optional)

QichenZhu commented 3 days ago

Proposal

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

The height of live markdown input doesn't fit its content on Android if it contains emojis.

What is the root cause of that problem?

MarkdownEmojiSpan uses font size in DIP units.

Screenshot 2024-11-02 at 11 52 28 PM

AbsoluteSizeSpan(int size, boolean dip) Set the text size to size physical pixels, or to size device-independent pixels if dip is true.

However, the text height measurement treats the font size as if it’s in pixels, so the measured height doesn't match the actual height.

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

Use pixels in MarkdownEmojiSpan, just like in MarkdownFontSizeSpan below.

Screenshot 2024-11-03 at 12 02 26 AM

What alternative solutions did you explore? (Optional)

N/A

DylanDylann commented 2 days ago

Reviewing on Monday

DylanDylann commented 1 day ago

@QichenZhu Your proposal doesn't work for me

Screenshot 2024-11-04 at 16 37 39
DylanDylann commented 1 day ago

@shahinyan11 Could you please provide a test branch?

QichenZhu commented 1 day ago

@DylanDylann Sorry I didn’t clearly mention that both arguments in the constructor need to change. Here’s the code I tested with. Could you double check?

node_modules/@expensify/react-native-live-markdown/android/src/main/java/com/expensify/livemarkdown/spans/MarkdownEmojiSpan.java

package com.expensify.livemarkdown.spans;

import android.text.style.AbsoluteSizeSpan;

import com.facebook.react.uimanager.PixelUtil;

public class MarkdownEmojiSpan extends AbsoluteSizeSpan implements MarkdownSpan {
  public MarkdownEmojiSpan(float fontSize) {
    super((int) PixelUtil.toPixelFromDIP(fontSize), false);
  }
}

Before:

1000000825-2024-11-04 10_12_30 900

After:

1000000827-2024-11-04 10_12_33 389

DylanDylann commented 1 day ago

@QichenZhu Thanks for your update

@QichenZhu's proposal looks good to me

🎀 👀 🎀 C+ Reviewed

melvin-bot[bot] commented 1 day ago

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

melvin-bot[bot] commented 3 hours ago

@francoisl @anmurali @DylanDylann 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!

melvin-bot[bot] commented 3 hours ago

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

Offer link Upwork job

melvin-bot[bot] commented 3 hours ago

📣 @QichenZhu 🎉 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 📖