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

Components: Refactor insertIndex from Inserter component #4551

Closed
wants to merge 1 commit into from

Conversation

aduth
Copy link
Member

@aduth aduth commented Jan 17, 2018

This pull request seeks to refactor the Inserter component to separate handling of insertion point and visibility. Previously the Inserter component was responsible for: setting the insertion point, showing the insertion point, and inserting a block at the current insertion point. To achieve this, it received two props insertIndex and insertionPoint which often -- but not always -- held the same value.

The changes here distinguish setting an insertion point to be the responsibility of where it is relevant; namely, the sibling inserter component. showInsertionPoint( index ) and hideInsertionPoint() have been replaced with toggleInsertionPointVisible( isVisible ) and setInsertionPointIndex( index ).

A hope here is to try to clarify a difference between an explicit insertion point (reflected in state.blockInsertionPoint) and the implicit insertion point (the logic contained within the getBlockInsertionPoint selector, inserting after content or the current block selection).

The main downside is that since there are now two separate actions for setting the insertion point index and its visibility, there may be separate renders which occur. This can be seen when, while a block is selected, you use the header inserter and then cancel both insertion and block selection by clicking on the editor background. The insertion point shows briefly at the bottom of the post content.

Testing instructions:

Verify that there are no regressions in the behavior of the insertion point, notably around selection (including multi-selection), sibling block insertion, and the header inserter (with and without selected block, in Visual and Text modes).

Ensure that unit tests pass:

npm test

@aduth aduth added the [Feature] Inserter The main way to insert blocks using the + button in the editing interface label Jan 17, 2018
@aduth
Copy link
Member Author

aduth commented Jan 30, 2018

Currently made redundant with #4539.

@aduth aduth closed this Jan 30, 2018
@aduth aduth deleted the update/inserter-insertion-point branch January 30, 2018 19:33
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant