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

Move select toolbar to header #955

Merged
merged 3 commits into from
Jun 3, 2017
Merged

Move select toolbar to header #955

merged 3 commits into from
Jun 3, 2017

Conversation

ellatrix
Copy link
Member

Did this quick while on the road. 🚗

See #951.

@ellatrix ellatrix requested a review from jasmussen May 31, 2017 09:30
@jasmussen
Copy link
Contributor

Did this quick while on the road. 🚗

Whaaaa? Hopefully not while driving! :D

Love it, works great! I pushed a color change to the bottom toolbar.

I can't deselect by clicking outside blocks, though — only with the close button (though the close button deselect behavior is correct).

Also, every once in a while when selecting across blocks there is some flickering happening. I can't quite pin down what makes it happens, feels like it happens when you start selecting inside text and across image blocks, but not sure.

@jasmussen
Copy link
Contributor

I'm getting a React JS error when opening post settings, an error I'm not seeing in master:

screen shot 2017-05-31 at 11 49 50

@ellatrix
Copy link
Member Author

Also, every once in a while when selecting across blocks there is some flickering happening. I can't quite pin down what makes it happens, feels like it happens when you start selecting inside text and across image blocks, but not sure.

Yeah, this happens in master too. I've experienced it too, but usually only in the beginning. I think it might be because the editors are still loading or something, I'm not quite sure. Should be looked into separately.

@ellatrix
Copy link
Member Author

@jasmussen I'm getting a React error in master too.

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.

@ellatrix
Copy link
Member Author

I can't deselect by clicking outside blocks, though — only with the close button (though the close button deselect behavior is correct).

Ooops, there was a typo in the code.

@ellatrix
Copy link
Member Author

@jasmussen The error comes from ccf8728, not this branch.

@mtias mtias added [Feature] Blocks Overall functionality of blocks General Interface Parts of the UI which don't fall neatly under other labels. labels May 31, 2017
@ellatrix
Copy link
Member Author

ellatrix commented Jun 1, 2017

@jasmussen Does this look ok to go in?

import { getSelectedBlocks } from '../selectors';

function Header( { selectedBlocks } ) {
if ( selectedBlocks.length ) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we have two concepts of selected blocks? One for singular selection, and one for multi-selection? Can we consolidate these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we do, also two separate entries in state, mostly to keep the selection object for a single block.

Copy link
Member

Choose a reason for hiding this comment

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

If my confusion could serve as evidence, it would be good if we could better distinguish or eliminate the differences between the separate selected state.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. It sound like that's something for a separate ticket/PR as this code just reads the state.

Copy link
Member

Choose a reason for hiding this comment

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

That's fine.


function Header( { selectedBlocks } ) {
if ( selectedBlocks.length ) {
return <MultiSelectHeader selectedBlocks={ selectedBlocks } />;
Copy link
Member

Choose a reason for hiding this comment

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

Depending to which extreme we want to take component self-sufficiency, <MultiSelectHeader /> is equally capable of retrieving the currently selected blocks. We could even adopt a pattern where we always render <MultiSelectHeader />, but it returns null if there's not a multiple selection.

Not really suggesting any change here, just food for thought.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right here, what you're suggesting sounds way better.

handleClickOutside() {
this.props.clearSelectedBlock();
handleClickOutside( { target } ) {
if ( target.nodeName !== 'BUTTON' ) {
Copy link
Member

@aduth aduth Jun 1, 2017

Choose a reason for hiding this comment

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

Is this specifically targeting the <MultiSelectHeader /> button? Are we trying to resolve a race condition between when deleting blocks from header, and clicking outside? Is there any other way we could ensure the "Delete" logic is triggered first? setTimeout is an option here; not great, but perhaps still better than targeting other elements on the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll have a closer look at this.

@jasmussen
Copy link
Contributor

Does this look ok to go in?

Visually fine, yes, I defer to Andrew on the code.

@ellatrix ellatrix force-pushed the add/multi-select-sticky branch from 23a2c1a to 2b0696b Compare June 2, 2017 18:39
@ellatrix
Copy link
Member Author

ellatrix commented Jun 3, 2017

Concerns addressed, so I'm going to merge. Let's iterate in further PRs.

@ellatrix ellatrix merged commit 9b72cc4 into master Jun 3, 2017
@ellatrix ellatrix deleted the add/multi-select-sticky branch June 3, 2017 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks General Interface Parts of the UI which don't fall neatly under other labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants