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/28342: Task description does not remove empty quotes #29144

Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/pages/tasks/NewTaskDescriptionPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -40,6 +41,8 @@ const defaultProps = {
},
};

const parser = new ExpensiMark();

function NewTaskDescriptionPage(props) {
const {inputCallbackRef} = useAutoFocusInput();

Expand Down Expand Up @@ -74,7 +77,7 @@ function NewTaskDescriptionPage(props) {
<View style={styles.mb5}>
<InputWrapperWithRef
InputComponent={TextInput}
defaultValue={props.task.description}
defaultValue={parser.htmlToMarkdown(parser.replace(props.task.description))}
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh? Why are we converting to HTML and back to markdown?? This was not part of the proposal, was it?

Copy link
Contributor Author

@DylanDylann DylanDylann Oct 19, 2023

Choose a reason for hiding this comment

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

I have mentioned in this #29144 (comment)

So when submitting the description to BE, I keep using the original logic (let BE save the mark down string) rather than convert mark down to HTML.

Copy link
Contributor

@iwiznia iwiznia Oct 19, 2023

Choose a reason for hiding this comment

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

Hmmmm but comments are saved in the DB as html, no? So this would mean saving things differently than for comments? That does not sound correct...right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Yeah. Comments and Privates notes are saved on BE side as HTML. As I mentioned above, with the description, I found out that if we let BE store the HTML, for example,
    Hello
    123, it just stores as "Hello123"
  • So if we want to store description as HTML, we need the BE fix

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I don't think we would want to save html in one place and markdown in the other.... can you comment on the OG issue what changes would need to be done in the backend please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iwiznia just requested confirm here #28342

inputID="taskDescription"
label={props.translate('newTaskPage.descriptionOptional')}
accessibilityLabel={props.translate('newTaskPage.descriptionOptional')}
Expand Down
7 changes: 6 additions & 1 deletion src/pages/tasks/NewTaskDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import PropTypes from 'prop-types';
import React, {useEffect, useState} from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -38,6 +39,8 @@ const defaultProps = {
task: {},
};

const parser = new ExpensiMark();

function NewTaskDetailsPage(props) {
const [taskTitle, setTaskTitle] = useState(props.task.title);
const [taskDescription, setTaskDescription] = useState(props.task.description || '');
Expand All @@ -46,7 +49,7 @@ function NewTaskDetailsPage(props) {

useEffect(() => {
setTaskTitle(props.task.title);
setTaskDescription(props.task.description || '');
setTaskDescription(parser.htmlToMarkdown(parser.replace(props.task.description || '')));
}, [props.task]);

/**
Expand Down Expand Up @@ -117,6 +120,8 @@ function NewTaskDetailsPage(props) {
autoGrowHeight
submitOnEnter={!Browser.isMobile()}
containerStyles={[styles.autoGrowHeightMultilineInput]}
textAlignVertical="top"
defaultValue={parser.htmlToMarkdown(parser.replace(taskDescription))}
inputStyle={[styles.verticalAlignTop]}
value={taskDescription}
onValueChange={(value) => setTaskDescription(value)}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/tasks/TaskDescriptionPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useFocusEffect} from '@react-navigation/native';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import React, {useCallback, useRef} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -34,6 +35,7 @@ const defaultProps = {
report: {},
};

const parser = new ExpensiMark();
function TaskDescriptionPage(props) {
const validate = useCallback(() => ({}), []);

Expand Down Expand Up @@ -98,7 +100,7 @@ function TaskDescriptionPage(props) {
name="description"
label={props.translate('newTaskPage.descriptionOptional')}
accessibilityLabel={props.translate('newTaskPage.descriptionOptional')}
defaultValue={(props.report && props.report.description) || ''}
defaultValue={parser.htmlToMarkdown((props.report && parser.replace(props.report.description)) || '')}
ref={(el) => {
if (!el) {
return;
Expand Down
Loading