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

Editor: Fix tags bug by using correct container for blur event #2054

Merged
merged 3 commits into from
Jan 5, 2016

Conversation

nylen
Copy link
Contributor

@nylen nylen commented Jan 1, 2016

Fixes #1884, and other strange behavior, which I suspect is also related to the following forum threads:

Chrome Safari
The tag suggestion list flickers when you select a tag, and sometimes the tag you select doesn't get added.
The tag suggestion list disappears when you select a tag, and sometimes the tag you select doesn't get added.

The reason this code change fixes these issues is that the blur event target is usually the text input, but we need to check the entire TokenField container for the relatedTarget instead. Looks like this was changed here - cc @aduth.

To test

@nylen nylen added [Feature] Post/Page Editor The editor for editing posts and pages. Components labels Jan 1, 2016
@nylen nylen self-assigned this Jan 1, 2016
@nylen nylen added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 1, 2016
@@ -81,7 +91,8 @@ var TokenField = React.createClass( {
scrollIntoView={ this.state.selectedSuggestionScroll }
isExpanded={ this.state.isActive }
onHover={ this._onSuggestionHovered }
onSelect={ this._onSuggestionSelected } />
onSelect={ this._onSuggestionSelected }
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I just had the linter warn me on a branch that the closing tag should be on the same line as the last prop. This was "new" to me, but figured I'd mention it here too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just had the linter warn me on a branch that the closing tag should be on the same line as the last prop.

I believe this only applies to self-closing tags, and was added in #1807.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm strongly in favor of putting the /> (and even the > for tags with children) on the following line, de-indented 1 level:

  • Like </div> ); } etc. that often appear immediately below, it denotes the end of a block
  • Easier to rearrange props, like trailing , in arrays

We have lots of code in both styles in Calypso. If we want to do something about this, let's do it in a separate PR and either remove that linter rule or update our code to this style.

@ralder
Copy link
Contributor

ralder commented Jan 1, 2016

Also for Firefox and IE11 there need using in _onBlur handler instead event.relatedTarget

 var relatedTarget = event.relatedTarget ||
            event.explicitOriginalTarget || // FF
            document.activeElement; // IE11

details about it facebook/react#2011

@aduth
Copy link
Contributor

aduth commented Jan 4, 2016

I can confirm that event.target was indeed the culprit. Using event.currentTarget would be an alternative fix, though I think the changes here are more explicit.

Marking as needs changes per linting error and response to above comment.

@aduth aduth added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 4, 2016
@nylen nylen added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. OSS Citizen and removed [Status] Needs Author Reply labels Jan 4, 2016
@nylen
Copy link
Contributor Author

nylen commented Jan 4, 2016

Thanks for the tip @ralder! I needed to use event.nativeEvent.explicitOriginalTarget instead but your suggestion fixes #1814. This is now ready for review again. Edit: Fixing the failing tests now

@nylen
Copy link
Contributor Author

nylen commented Jan 4, 2016

Fixed the failing tests - looks like it's due to a React TestUtils thing-I-thought-was-a-bug-but-isnt (facebook/react#5778).

@aduth
Copy link
Contributor

aduth commented Jan 5, 2016

Looks good to me 👍

Two things to follow-up on:

  • Let's not just leave the lint warning, and submit either an issue or pull request to remove the linting rule
  • Should tags that are already added not be shown in the available suggestions? Do we have an issue tracking this?

@nylen
Copy link
Contributor Author

nylen commented Jan 5, 2016

@nylen nylen added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 5, 2016
nylen added a commit that referenced this pull request Jan 5, 2016
Editor: Fix tags bug by using correct container for blur event
@nylen nylen merged commit b7cdb62 into master Jan 5, 2016
@nylen nylen deleted the fix/cant-add-tags-maybe branch January 5, 2016 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Components [Feature] Post/Page Editor The editor for editing posts and pages. OSS Citizen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor: cannot select tags by clicking on list of previously used tags
5 participants