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 outside click logic for committing changes #1404

Merged
merged 4 commits into from
Nov 28, 2018

Conversation

amanmahajan7
Copy link
Contributor

No description provided.

Copy link
Contributor

@Runi-B Runi-B left a comment

Choose a reason for hiding this comment

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

Good work, pal. Only 2 minor suggestions

handleDocumentClick = (e) => {
const { target } = e;
const { container, editor } = this;
const isClickedInsideEditorContainer = container !== null && (target === container || container.contains(target));
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of container !== null && ... could we use one of the below?

Suggested change
const isClickedInsideEditorContainer = container !== null && (target === container || container.contains(target));
const isClickedInsideEditorContainer = container && (target === container || container.contains(target));
Suggested change
const isClickedInsideEditorContainer = container !== null && (target === container || container.contains(target));
const isClickedInsideEditorContainer = !!container && (target === container || container.contains(target));

const { container, editor } = this;
const isClickedInsideEditorContainer = container !== null && (target === container || container.contains(target));
let isClickedInsideEditor = false;
if (editor !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As above...

Suggested change
if (editor !== null) {
if (editor) {
Suggested change
if (editor !== null) {
if (!!editor) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

React will assign the current property with the DOM element when the component mounts, and assign it back to null when it unmounts

I usually prefer an explicit check than using the !! operator but either works

@amanmahajan7 amanmahajan7 removed the WIP label Nov 28, 2018
@amanmahajan7 amanmahajan7 merged commit 1fbb0d3 into master Nov 28, 2018
@amanmahajan7 amanmahajan7 deleted the am-fix-outside-click branch November 28, 2018 21:16
rossjp pushed a commit to rossjp/react-data-grid that referenced this pull request Dec 14, 2018
* Fix outside click logic for committing changes

* - Cleanup up outside click logic
- Fix unit tests

* Cleanup up if condition

* Add unit tests for editors using portals
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