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

Replaced focus with isSelected verification on hooks. #5004

Merged

Conversation

jorgefilipecosta
Copy link
Member

This fixes a bug where classes and anchor inputs are not being shown.

The focus property has been removed, and now isSelected should be used. During this change, hooks were not updated causing our checks condition to fail.

Props to @phpbits for reporting this problem.

How Has This Been Tested?

Verify custom anchor input appears e.g: in the heading block.
Verify custom class input appears e.g: in the image block.

This fixes a bug where classes and anchor inputs are not being shown.
@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta Wow! That escalated quickly :D You are very welcome! I didn't know that focus is now isSelected. I'll try this on my end too. Thank you very much!

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.

Thanks for the fix. A quick e2e test for the anchor/classname feature would be good I think.

@jorgefilipecosta jorgefilipecosta merged commit 2efa4dc into master Feb 12, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/replaced-focus-check-with-is-selected-hooks branch February 12, 2018 13:31
@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta @youknowriad have you tried adding value and saving it? It seems not saving, not sure if it's only on my end. Would you mind checking too? Thanks!

@jorgefilipecosta
Copy link
Member Author

Hi @phpbits in my tests changes to anchor and classes get correctly saved. If testing in master the problem happens, feel free to open a new issue, and we will look further.

@youknowriad
Copy link
Contributor

@phpbits it saves for me as well.

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta @youknowriad Sorry! Just figured it out too :) The problem is with the Classic Block. It's not saving while the others do. Do I need to open a new issue about this? You can also try it and let me know if you are having the same issue. Thanks!

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

Same with Columns Block, also not saving but probably because it's still experimental. Haven't checked all blocks though, there might be more that are not saving. Thanks!

@jorgefilipecosta
Copy link
Member Author

jorgefilipecosta commented Feb 12, 2018

@phpbits on the classic block, given the nature of the block, custom classes functionality in inspector should not be allowed. The block had an unsupported declaration for it, but the property name changed and the declaration was not updated in accordance. A PR that fixes this problem was submitted #5005. Thank you for reporting this!

@phpbits
Copy link
Contributor

phpbits commented Feb 12, 2018

@jorgefilipecosta you are very welcome :) Thank you too for the fast response! Is that also the reason why the block contents are not saving for Classic Block and Column Blocks? Thanks!

@zgordon
Copy link

zgordon commented Feb 12, 2018

Hey folks, just curious if this works for fields within a block being selected or just an entire block being selected? Thanks!

@youknowriad
Copy link
Contributor

Hey folks, just curious if this works for fields within a block being selected or just an entire block being selected? Thanks!

@zgordon What do you mean exactly? If you're asking if selecting a field in a block, selects the block, the answer is yes.

@zgordon
Copy link

zgordon commented Feb 13, 2018

Thanks @youknowriad :)

I was actually referring to technique for checking if a specific field is selected in a block (particularly managing focus in fields in blocks with multiple fields).

Was also wondering if focus could/would maintain backwards compatibility for a bit?

@youknowriad
Copy link
Contributor

youknowriad commented Feb 13, 2018

@zgordon You'd have to implement as local state in this case, you might want to take a look at how we do it using withState in the quote block for instance.

And we're mainting backwards compatibility for simple usage !! focus && <BlockControls as it's the most common usage. It's hard to ensure backward compatibility for setFocus calls. I mean it's possible but I don't think it's worth it, I suspect very low usage for it.

@zgordon
Copy link

zgordon commented Feb 13, 2018

@youknowriad that all makes total sense!

Thank you!!

#GoState

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants