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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug: Refactor showBodyText #182

Open
1 task done
mithunsridharan opened this issue Nov 7, 2022 · 0 comments
Open
1 task done

馃悰 Bug: Refactor showBodyText #182

mithunsridharan opened this issue Nov 7, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@mithunsridharan
Copy link

mithunsridharan commented Nov 7, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The method showBodyText appears in 4 files. This method only sanitises input text. Currently, it accepts an object. Instead, the following approach could reduce redundant code and be moved to a base / core method that could be reused across multiple contexts:

  const showBodyText = (item: EducationDataObject) =>
    sanitizeHTML(item.description.toString()).length > 0;

For example, the above code is invoked as follows:

          <DataRow>
            {showBodyText(item) && <BodyText content={item.description} />}
          </DataRow>

Expected Behavior

Instead, change the implementation to:

  const showBodyText = (item: Content) =>
    sanitizeHTML(item.toString()).length > 0;

And, invoke this method:

          <DataRow>
            {showBodyText(item.description) && <BodyText content={item.description.toString()} />}
          </DataRow>

Steps To Reproduce

Code refactoring idea

Environment

- Platform: Desktop
- OS: Mac OSX Ventura
- Browser: Safari
- Version: Version 16.1 (18614.2.9.1.12)
- Screen Size(in inch)(Approx): 16:9

Anything else?

No response

@mithunsridharan mithunsridharan added the bug Something isn't working label Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant