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

Reuse isHorizontalEdge for RichText #5159

Merged
merged 1 commit into from
Feb 22, 2018
Merged

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Feb 20, 2018

Description

This branch removes some duplicate logic in RichText where isHorizontalEdge can be used. We do have to move dom utils though.

How Has This Been Tested?

Make sure backspace can still be used to merge blocks. Also make sure blocks are not merged unless the caret is really at the start or end.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@ellatrix ellatrix force-pushed the try/richtext-duplicate-logic branch from 5530ffe to dbad2b2 Compare February 20, 2018 10:53
@ellatrix ellatrix requested a review from a team February 20, 2018 10:55
@aduth
Copy link
Member

aduth commented Feb 21, 2018

A meta-question which is not so specific to this pull request: What is the long-term plan for utils? It's convenient because it's already exposed as a module, but it concerns me especially because its a single shared scope of variables. The fact that we have named files within it exported by index.js makes me wonder why those individual files aren't themselves modules, e.g. @wordpress/dom. Is it merely the fact that there's overhead in creating a module that deters us from wanting to do this? Or is this too granular? Is utils a legitimate and useful classifier for these types of functions?

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

A nice consolidation 👍

@ellatrix
Copy link
Member Author

@aduth I was wondering the same thing... Also a lot of these functions in dom.js seem like random utility things rather than some well baked module. Not sure what to do for now.

@ellatrix ellatrix merged commit 35122e1 into master Feb 22, 2018
@ellatrix ellatrix deleted the try/richtext-duplicate-logic branch February 22, 2018 15:51
@ellatrix
Copy link
Member Author

Oh and apart from getScrollContainer (not sure it belongs to that file), these are selection API helper functions. Maybe we should rename that file and/or move it to a separate module.

@youknowriad
Copy link
Contributor

I believe this PR introduced this regression #5345

This probably means isHorizontalEdge works differently than isEndOfEditor

@ellatrix
Copy link
Member Author

ellatrix commented Mar 2, 2018

@youknowriad It works the same but doesn't seem to account for empty containers.

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