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

fix: IOU - one character descriptions are not saved #343

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface MarkdownTextInputProps extends TextInputProps {

interface MarkdownNativeEvent extends Event {
inputType: string;
data: string;
}

type Selection = {
Expand Down Expand Up @@ -337,14 +338,14 @@ const MarkdownTextInput = React.forwardRef<TextInput, MarkdownTextInputProps>(
}
const changedText = e.target.innerText;

if (compositionRef.current) {
updateTextColor(divRef.current, changedText);
const nativeEvent = e.nativeEvent as MarkdownNativeEvent;
if (compositionRef.current && (nativeEvent.inputType !== 'insertCompositionText' || nativeEvent.data !== '*')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt it will function properly if the single character entered is * here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when it's just a single character '*', the previous condition composition.current is false.

Copy link

@sobitneupane sobitneupane May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we return early if inputType is insertCompositionText?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed my proposal again, and I apologize for modifying the wrong code while handling conflicting situations.

The condition here is that it only early returns if the composite and type are insertCompositionText, and it is not ** to bold.

updateTextColor(divRef.current, e.target.innerText);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed the change introduced by this PR.

Suggested change
updateTextColor(divRef.current, e.target.innerText);
updateTextColor(divRef.current, changedText);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sobitneupane i copy the builded into App/node_modules/@expensify/react-native-live-markdown/lib/commonjs/MarkdownTextInput.web.jsMarkdownTextInput.web.js.

and the test step

Manual Tests

On Android mWeb

  1. Navigate to staging.new.expensify.com
  2. Click on FAB > Submit expense > Manual
  3. Input an amount
  4. Select a user
  5. Click on "Description"
    "The system keyboard must be set to predictive text mode, or what's called autocomplete mode. Just type a few characters."
  6. Click save when the system's predictive text is active.

compositionRef.current = false;
return;
}

let text = '';
const nativeEvent = e.nativeEvent as MarkdownNativeEvent;
switch (nativeEvent.inputType) {
case 'historyUndo':
text = undo(divRef.current);
Expand Down
Loading