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

Block arrow key navigation #595

Closed
wants to merge 1 commit into from
Closed

Block arrow key navigation #595

wants to merge 1 commit into from

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented May 1, 2017

WIP. Does not set caret at start or end based on the direction yet.

@ellatrix
Copy link
Member Author

ellatrix commented May 1, 2017

See #520.

@ellatrix ellatrix self-assigned this May 1, 2017
@ellatrix
Copy link
Member Author

ellatrix commented May 1, 2017

These are issues where I think it would make much more sense to have a contentEditable container for the whole editor... Having that doesn't imply any fragility btw, if special keys etc. are moved to reducers. (See Draft.js too). Fragility around nested editable fields can easily be solved by taking the attribute away: take it away from the root and add to the nested field on focus, add back to the root and take away from the nested field on blur.

Anyway, this seems a fine temporary solution.

@ellatrix
Copy link
Member Author

ellatrix commented May 1, 2017

Hm, there's also an issue with the link boundary stuff adding a zero width space so that the caret is not at the start or end.

}, null );

if ( targetNode ) {
targetNode.focus();
Copy link
Contributor

@youknowriad youknowriad May 2, 2017

Choose a reason for hiding this comment

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

I would prefer to avoid the imperative approach here and rely on the redux flow for focusing the target. something like:

const blockUid = targetNode.closest( '[data-block-uid]' ).attr( 'data-block-uid' );
const editable = targetNode.closest( '[data-block-editable]' ).attr( 'data-block-editable' );
const offset = before ? -1 : 0;
onFocus( blockUid, { editable, offset } );

This assumes we add the data-block-uid to each block container and a data-block-editable (optional) to blocks with multiple editables.

(I'm secretly hoping we could use these attributes to drop the focus, updateFocus and mergeWithPrevious completely from the block edit function.)

@aduth Thoughts

Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of dispatching to Redux to shift focus, and the idea to eliminate focus props from the edit implementation. I'm not so sure of assuming attributes on an ancestor node and using them as action properties. But I've not digested this deeply and don't have alternatives to suggest at the moment.

@mtias mtias added [Status] In Progress Tracking issues with work in progress [Feature] Blocks Overall functionality of blocks Framework Issues related to broader framework topics, especially as it relates to javascript labels May 2, 2017
@jasmussen
Copy link
Contributor

With #520 closed, perhaps we should close this also?

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 Framework Issues related to broader framework topics, especially as it relates to javascript [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants