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(components): guard event.persist() calls #14482

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

tay1orjones
Copy link
Member

@tay1orjones tay1orjones commented Aug 21, 2023

Raised in slack

Even though persist() is available and just a noop in later versions of react that don't have event pooling anymore, we still need to guard calls to these. It was pointed out that if we begin to call persist(), it can break tests where event handlers are mocked. Example:

On our app we mock onChange function passed to the textArea like:

let onChange = jest.fn();
    let component = getComponent('hello', onChange);
    component
      .find('textarea')
      .props()
      .onChange({ target: { value: '   test123' }, persist: jest.fn() });

I had to add persist: jest.fn() into this bcs of that change

Changelog

Changed

  • modify all event.persist() calls to be guarded via event?.persist?.();

References

@netlify
Copy link

netlify bot commented Aug 21, 2023

Deploy Preview for carbon-components-react ready!

Name Link
🔨 Latest commit 831514b
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/64e3b9a40565ba0007cf334e
😎 Deploy Preview https://deploy-preview-14482--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Aug 21, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 831514b
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/64e3b9a4249f940008df0169
😎 Deploy Preview https://deploy-preview-14482--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@darq37 darq37 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

LGTM!

@tw15egan tw15egan added this pull request to the merge queue Aug 22, 2023
Merged via the queue into carbon-design-system:main with commit 8a8063b Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants