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

Inserter - show Picker with registered blocks to choose from #112

Merged

Conversation

mzorz
Copy link
Contributor

@mzorz mzorz commented Aug 14, 2018

Supersedes already reviewed/approved #105 to clean commit history

This completes a very draft, initial 1st iteration on implementing the inserter flow. With this, the flow goes roughly along the lines of the expected actions like this:

  1. focusing on an item shows an item toolbar which for now currently includes the + button to insert a new item (this + trigger will be moved to the toolbar as per the designs Inserter #58 (comment))
  2. tapping on + makes a RN Picker show up
  3. tap on the picker to choose the type of block you'd like to insert
  4. a newly created block is inserted right below the block that was being focused on.

inserter-picker

Known issues:

For this I'm working on another implementation with a modal dialog and a flatlist, but wanted to continue to put this PR up and complete a first "working" flow at least.

@mzorz
Copy link
Contributor Author

mzorz commented Aug 14, 2018

@koke This code has already been reviewed / approved in #105 except for this particular line here https://github.com/wordpress-mobile/gutenberg-mobile/pull/112/files#diff-2d50daf729e068ecebcce113d1ce7f9aR92 which has been added after the fix in #108. Would you like to give it a quick look and re-approve, or otherwise make any comments as you see fit? Thanks in advance 🙇

@mzorz mzorz changed the base branch from try/inserter-take1-state-props-direct-insert-take2 to feature/inserter August 14, 2018 17:16
newBlock.focused = false;

// set it into the datasource, and use the same object instance to send it to props/redux
this.state.dataSource.splice( focusedItemIndex + 1, 0, newBlock );
Copy link
Member

Choose a reason for hiding this comment

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

Aren't you supposed to modify state only by calling setState? I still have a lot to learn about React and I'm not sure which side effects this might have.

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 know, right? 😉 That's exactly my understanding from my learnup that ended in the elaborate description of #95. But, one of the troublesome things that appear here is that the list will redraw itself on each state change as per React's mandate, which is something we still have trouble digesting (feels super counterintuitive after having learnt to deal with recycled views and making good use of list updates for years). Also this kills the native animations when moving blocks, which was something that was tested early on when picking the List component, as ultimately we want to have a best UX on Gutenberg when moving blocks around.

Long story short, we are keeping the same state on both sides (RecyclerView and redux) to make sure we can still use the fine grained RecyclerView API to move items around and get native animations to work, without incurring in heavy lifting. More info in #108.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. I'm going to go with 👍 for now since I don't want to be blocking on this, but it seems to me as if the recyclerlist library wasn't implemented in a way that's consistent with React's declarative style. If I understood the code correctly, the list isn't implementing shouldComponentUpdate, and the README seems to imply that you should update the contents by manipulating the data source directly.

What I would expect is that you'd call setState and the list would deal with calculating what changed from the previous one and what needs to be inserted/deleted/updated. But this is what we have for now 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the same boat here 😄. We could set some time apart to further investigate and see if using a FlatList and non-native animations makes the cut for both platforms and eventually go with it, making good use of the React pattern 👍

newBlock.focused = false;

// set it into the datasource, and use the same object instance to send it to props/redux
this.state.dataSource.splice( focusedItemIndex + 1, 0, newBlock );
Copy link
Member

Choose a reason for hiding this comment

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

Got it. I'm going to go with 👍 for now since I don't want to be blocking on this, but it seems to me as if the recyclerlist library wasn't implemented in a way that's consistent with React's declarative style. If I understood the code correctly, the list isn't implementing shouldComponentUpdate, and the README seems to imply that you should update the contents by manipulating the data source directly.

What I would expect is that you'd call setState and the list would deal with calculating what changed from the previous one and what needs to be inserted/deleted/updated. But this is what we have for now 🤷‍♂️

@koke koke merged commit 57650c6 into feature/inserter Aug 16, 2018
@koke koke deleted the try/inserter-take1-state-props-show-reg-blocks-take2 branch August 16, 2018 15:10
hypest pushed a commit that referenced this pull request Jan 18, 2019
…l-position

Add onCaretVerticalPositionChange event
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.

2 participants