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

Refactor the EditableText component to reduce code duplication. #194

Open
raphaelweis opened this issue Jun 5, 2024 · 1 comment
Open
Assignees

Comments

@raphaelweis
Copy link
Contributor

In editable text, the functions handleImageUrl and handleBlur are almost identical, with the main difference being the source of the text to update. These can be combined into a single function allowing it's users to update the text for a passage margin, regardless of the input method.

@raphaelweis raphaelweis self-assigned this Jun 5, 2024
@benel
Copy link
Member

benel commented Jun 12, 2024

Thank you for this suggestion.

Please note that a similar refactoring has recently been done to reuse code between handleClick and useEffect:

let updateEditedDocument = () => backend.getDocument(id)
.then((x) => {
x = x.error
? {_id: uuid(), text: `{${rubric}}`, isPartOf, links}
: x;
setEditedDocument(x);
return x;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants