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 8 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
Expand Up @@ -3,6 +3,7 @@ import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import {useFocusEffect} from '@react-navigation/native';
import PropTypes from 'prop-types';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import compose from '../../libs/compose';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
Expand Down Expand Up @@ -39,6 +40,8 @@ const defaultProps = {
},
};

const parser = new ExpensiMark();

function NewTaskDescriptionPage(props) {
const inputRef = useRef(null);
const focusTimeoutRef = useRef(null);
Expand Down Expand Up @@ -91,7 +94,7 @@ function NewTaskDescriptionPage(props) {
>
<View style={styles.mb5}>
<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
6 changes: 5 additions & 1 deletion src/pages/tasks/NewTaskDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useEffect, useRef, useState} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import compose from '../../libs/compose';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
Expand Down Expand Up @@ -36,14 +37,16 @@ const defaultProps = {
task: {},
};

const parser = new ExpensiMark();

function NewTaskDetailsPage(props) {
const inputRef = useRef();
const [taskTitle, setTaskTitle] = useState(props.task.title);
const [taskDescription, setTaskDescription] = useState(props.task.description || '');

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

/**
Expand Down Expand Up @@ -114,6 +117,7 @@ function NewTaskDetailsPage(props) {
submitOnEnter={!Browser.isMobile()}
containerStyles={[styles.autoGrowHeightMultilineInput]}
textAlignVertical="top"
defaultValue={parser.htmlToMarkdown(parser.replace(taskDescription))}
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
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import {View} from 'react-native';
import {useFocusEffect} from '@react-navigation/native';
import {withOnyx} from 'react-native-onyx';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
Expand Down Expand Up @@ -40,6 +41,7 @@ const defaultProps = {
report: {},
};

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

Expand Down Expand Up @@ -103,7 +105,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