Skip to content

Conversation

@andrewiggins
Copy link
Member

No description provided.

@andrewiggins andrewiggins force-pushed the simulate-events-on-components branch 2 times, most recently from 4eb3914 to 4a5c388 Compare October 29, 2022 00:18
Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

Hi Andrew,

I took a look over this and left some comments and questions. Give me a ping once you've had a chance to look over them.

this._mountRenderer.simulateEvent(node, eventName, args);
const handler = node.props[propFromEvent(eventName)];
if (handler) {
handler(...args);
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a significant change to how event simulation works with shallow rendering. Can you provide some more context here? This isn't going to cause a problem for the company I work for as we don't use shallow rendering, but it could potentially be a surprise for other users. If we do decide to do this, it ought to be marked as a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

This change was just to bring our adapter into alignment with the React adapter. See my other comment for the source.

Yes, good call. We should release this as a breaking change. Should I retarget this PR to a "v5" branch we can release after gathering a couple of changes?

To be clear, my end goal here is to bring our enzyme adapter and react's enzyme adapter a bit closer in feature parity to make migrating easier.

Copy link
Member

Choose a reason for hiding this comment

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

Should I retarget this PR to a "v5" branch we can release after gathering a couple of changes?

Are there other breaking changes that you expect may be needed soon?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure yet. I'm still exploring/discovering what behaviors of the React 16 adapter our existing tests rely on, so it is possible. I imagine within a week or two I'll have a good grasp of what they are and if they are breaking or not.

Copy link
Member

Choose a reason for hiding this comment

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

One possibility to avoid the need for a separate branch would be to add a feature flag in the adapter's configuration to control which behavior is used. The flag can be set to preserve the current behavior and then flipped in the next major release.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh nice! I've hidden the new behavior behind a feature flag passed into the Adapter constructor.

@andrewiggins
Copy link
Member Author

@robertknight Responded to your comments. Let me know what you think!

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

LGTM. I added a note about a possible way of dealing with the breaking change without having to juggle a separate branch.

this._mountRenderer.simulateEvent(node, eventName, args);
const handler = node.props[propFromEvent(eventName)];
if (handler) {
handler(...args);
Copy link
Member

Choose a reason for hiding this comment

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

One possibility to avoid the need for a separate branch would be to add a feature flag in the adapter's configuration to control which behavior is used. The flag can be set to preserve the current behavior and then flipped in the next major release.

Copy link
Member Author

@andrewiggins andrewiggins left a comment

Choose a reason for hiding this comment

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

@robertknight Let me know if these changes match what you had in mind :)

this._mountRenderer.simulateEvent(node, eventName, args);
const handler = node.props[propFromEvent(eventName)];
if (handler) {
handler(...args);
Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh nice! I've hidden the new behavior behind a feature flag passed into the Adapter constructor.

@andrewiggins andrewiggins force-pushed the simulate-events-on-components branch from 6f0b62b to d3bf0fc Compare November 3, 2022 00:04
@andrewiggins andrewiggins merged commit 4130646 into master Nov 3, 2022
@andrewiggins andrewiggins deleted the simulate-events-on-components branch November 3, 2022 23:11
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.

3 participants