Skip to content

Commit

Permalink
Add missing method to list block.
Browse files Browse the repository at this point in the history
The list block does not have an on change set for it and is expected to
causing errors and no updating of the block attribute state.  This PR
copies the current implementation from a text block and enters it into
the list block.
  • Loading branch information
BE-Webdesign committed Apr 27, 2017
1 parent 36bbf96 commit 4bf2666
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion blocks/library/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,27 @@ registerBlock( 'core/list', {
}
],

edit( { attributes, focus, setFocus } ) {
edit( { attributes, setAttributes, focus, setFocus } ) {
const { nodeName = 'OL', items = [], align } = attributes;
const content = items.map( ( item, i ) => {
return <li key={ i }>{ item.value }</li>;
} );

const itemsFromContent = ( listContents ) => {
return listContents.map( ( listContent ) => ( { value: listContent.props.children } ) );
};

return (
<Editable
tagName={ nodeName.toLowerCase() }
style={ align ? { textAlign: align } : null }
value={ content }
focus={ focus }
onChange={ ( nextContent ) => {
setAttributes( {
items: itemsFromContent( nextContent )
} );
} }
onFocus={ setFocus }
className="blocks-list" />
);
Expand Down

0 comments on commit 4bf2666

Please sign in to comment.