Skip to content

Commit

Permalink
Merge pull request #29144 from DylanDylann/fix/28342-task-description…
Browse files Browse the repository at this point in the history
…-does-not-remove-empty-quotes

Fix/28342: Task description does not remove empty quotes
  • Loading branch information
iwiznia authored Nov 16, 2023
2 parents 1ddd581 + 31f2dc6 commit aacc1d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
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 styles = useThemeStyles();
const {inputCallbackRef} = useAutoFocusInput();
Expand Down Expand Up @@ -75,7 +78,7 @@ function NewTaskDescriptionPage(props) {
<View style={styles.mb5}>
<InputWrapperWithRef
InputComponent={TextInput}
defaultValue={props.task.description}
defaultValue={parser.htmlToMarkdown(parser.replace(props.task.description))}
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 styles = useThemeStyles();
const [taskTitle, setTaskTitle] = useState(props.task.title);
Expand All @@ -47,7 +50,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 @@ -118,6 +121,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 styles = useThemeStyles();
const validate = useCallback(() => ({}), []);
Expand Down Expand Up @@ -99,7 +101,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

0 comments on commit aacc1d4

Please sign in to comment.