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 unnecessary update of ra-input-rich-text on edit #3099

Merged
merged 7 commits into from
Apr 19, 2019

Conversation

roychoo
Copy link

@roychoo roychoo commented Apr 5, 2019

Hi,

in ra-input-rich-text,

whenever the text changes, below is the sequence of events happening.
Original text <p>test</p>

  1. User change text to <p>test1</p>
  2. onTextChange fired
  3. componentDidUpdate fired
  4. update happens as previous prop value is still <p>test</p>, but unecessary
  5. onTextChange fired again.
  6. stops there as the prevProp input value is the same as current prop input value

2nd issue is that, it seems quilljs is always adding additional <p> after this method

this.quill.setContents(
     this.quill.clipboard.convert(this.props.input.value)
)

ONLY for the text that has special characters, i.e ARTÍCULO 1.- El presente reglamento es de observancia obligatoria after you bold ARTÍCULO 1

fixes #3073

@djhi djhi added this to the 2.8.5 milestone Apr 5, 2019
@djhi
Copy link
Contributor

djhi commented Apr 5, 2019

Thanks! It seems the tests are failing though

@roychoo
Copy link
Author

roychoo commented Apr 13, 2019

Hi just want to check, did anyone take the opportunity to review the code?

Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

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

Thanks! I'll wait for another core team member to review before merging though

test-setup.js Show resolved Hide resolved
packages/ra-input-rich-text/src/index.spec.js Outdated Show resolved Hide resolved
packages/ra-input-rich-text/src/index.spec.js Show resolved Hide resolved
});

it('should call text-change event only once when editing', async () => {
const mockFn = jest.fn();
Copy link
Member

Choose a reason for hiding this comment

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

call it handleChange

Copy link
Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure ? I still see mockFn

Copy link
Author

@roychoo roychoo Apr 19, 2019

Choose a reason for hiding this comment

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

Oh sorry I misunderstood, I thought you meant the test description. Will make the required change in another 3 hours.

Copy link
Author

Choose a reason for hiding this comment

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

@djhi done.

packages/ra-input-rich-text/src/index.spec.js Show resolved Hide resolved
packages/ra-input-rich-text/src/index.spec.js Outdated Show resolved Hide resolved
Roy Choo added 4 commits April 16, 2019 16:03
quill require mock on some DOM apis while in test.
1. add reason for shim
2. add reason for using jest fake timers
@djhi djhi requested a review from fzaninotto April 19, 2019 12:04
});

it('should call text-change event only once when editing', async () => {
const mockFn = jest.fn();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure ? I still see mockFn

@djhi djhi modified the milestones: 2.8.5, 2.8.6 Apr 19, 2019
@djhi djhi merged commit 8b2cbc2 into marmelab:master Apr 19, 2019
@djhi
Copy link
Contributor

djhi commented Apr 19, 2019

Thanks!

@roychoo
Copy link
Author

roychoo commented Apr 19, 2019

Thanks for the review and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ra-input-rich-text breaks when using special characters
3 participants