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

Default Block Appender: Remove redundant event handlers #8714

Merged
merged 1 commit into from
Aug 15, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Aug 8, 2018

Related: #3623 (comment)

This pull request seeks to remove two of the three event handlers from the DefaultBlockAppender component: onClick and onKeyDown. This operates on the assumption that it is not possible to click or keydown the input without the onFocus event already having been handled, incurring the replacement of the default block.

Testing instructions:

Verify there are no regressions in the behavior of the default block appender.

Ensure end-to-end tests pass:

npm run test-e2e

@aduth aduth added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 8, 2018
@aduth aduth requested a review from youknowriad August 8, 2018 13:49
@aduth aduth added the [Feature] Inserter The main way to insert blocks using the + button in the editing interface label Aug 8, 2018
@youknowriad
Copy link
Contributor

The input has "role" button and in Firefox I think, buttons don't get the focus when you click on them, so might be good to check. I can do it a bit after.

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

buttons don't get the focus when you click on them, so might be good to check

Interesting to note and, if true, would be good to leave a comment clarifying this, as it's not obvious at a glance. I should clarify part of the goal here is to sanity check myself in asking "Is it possible to click a button without also causing it to receive focus?"

@youknowriad
Copy link
Contributor

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Yeah, just rediscovered this one as well. The difference is that this is not a button element, it's an input (type="text") with role of button. In brief testing in Firefox, it works as expected.

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Related: #1195 (comment) (when it was button)

@youknowriad
Copy link
Contributor

I tested and it works well in Firefox too. I wonder if we should be cautious? Is there any particular reason for removing those? Extra actions?

Anyway, I'm fine either way and there's a failing unit test.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Is there any particular reason for removing those?

If it serves no purpose, it shouldn't exist.

@youknowriad
Copy link
Contributor

My thinking was that maybe some browsers do weird things here, and it's hard to test all supported browsers, but yes, it's fine.

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Do you recall why we chose to use <input> in #1195 ? It looks from my comment at #1195 (comment) that earlier iterations of the branch had implemented it as a <button>.

I'm wondering if it's perhaps related to this.

@youknowriad
Copy link
Contributor

I think it's because of this #4829 (comment)

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

My thinking was that maybe some browsers do weird things here, and it's hard to test all supported browsers, but yes, it's fine.

I'd rather we have code we understand well than code which exists to hope to protect against some unknown browser behaviors.

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

I think it's because of this #4829 (comment)

That sounds right. What I'll do is add an inline code comment explaining both why it's an input and, if it were to be a button, the caveat about Firefox behavior.

@aduth aduth force-pushed the remove/default-appender-redundant-events branch from 16fa8aa to 88991ff Compare August 8, 2018 14:25
@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Added comment and updated tests in rebased 88991ff

@aduth
Copy link
Member Author

aduth commented Aug 8, 2018

Going to save this one for after release.

@aduth aduth added this to the 3.6 milestone Aug 8, 2018
@aduth aduth merged commit ad5e8d3 into master Aug 15, 2018
@aduth aduth deleted the remove/default-appender-redundant-events branch August 15, 2018 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants