Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Conversation

@jamessral
Copy link
Contributor

@jamessral jamessral commented Sep 27, 2018

Depending on this.state before and after the call can cause a subtle bug (in this case calling the onVisibilityChange callback twice when a parent component calls setState). Using the callback syntax to set state and the after set callback ensures that everything happens synchronously and the values in this.state are what we expect.

Edit: This is the real issue below

It is possible with event queueing that the caught event is that of the immediate child.
Include a
new and specific data attribute to reliably check to see if the Dropdown or the anchor is the target
of the click.
Also clean up setState logic in toggleVisibility to not rely on state before and
after setState call.

Copy link
Collaborator

@tadjohnston tadjohnston left a comment

Choose a reason for hiding this comment

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

Please use git cz to commit. It allows us to autogenerate changelogs and verion bump based on what you inputed using commitizen.

@tadjohnston
Copy link
Collaborator

Other than the one comment, 👍

@jamessral jamessral force-pushed the jsral/fix-set-state-callback branch from b14d58f to 87dcf73 Compare September 28, 2018 14:20
gabepages
gabepages previously approved these changes Sep 28, 2018
MiLandry
MiLandry previously approved these changes Sep 28, 2018
@jamessral jamessral dismissed stale reviews from MiLandry and gabepages via 882b6b3 September 28, 2018 15:45
@jamessral jamessral force-pushed the jsral/fix-set-state-callback branch from 87dcf73 to 882b6b3 Compare September 28, 2018 15:45
@jamessral
Copy link
Contributor Author

@gabepages @winstonmain Sorry, I didn't see the reviews from y'all. I'm still checking this out by linking it to rent-js and my premature rebase got rid of your comments

@jamessral jamessral force-pushed the jsral/fix-set-state-callback branch from 882b6b3 to 5670e67 Compare September 28, 2018 17:41
}
}

@autobind
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was unused

@jamessral jamessral force-pushed the jsral/fix-set-state-callback branch from 5670e67 to a475f41 Compare September 28, 2018 17:51
… for handleDocumentClick

affects: @rentpath/react-ui-core

It is possible with event queueing that the caught event is that of the immediate child.
Include a
new and specific data attribute to reliably check to see if the Dropdown or the anchor is the target
of the click.
Also clean up setState logic in toggleVisibility to not rely on state before and
after setState call.
@jamessral jamessral merged commit 36ff996 into master Oct 1, 2018
@jamessral jamessral deleted the jsral/fix-set-state-callback branch October 1, 2018 15:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants