Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handling the focus in the quote block
  • Loading branch information
youknowriad committed Apr 20, 2017
commit 5686bd88fef9faf541be7f3e48d356229dadf8f1
30 changes: 19 additions & 11 deletions blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ registerBlock( 'core/quote', {
citation: html( 'footer' )
},

edit( { attributes, setAttributes } ) {
edit( { attributes, setAttributes, focus, updateFocus } ) {
const { value, citation } = attributes;

return (
Expand All @@ -31,16 +31,24 @@ registerBlock( 'core/quote', {
( paragraphs ) => setAttributes( {
value: fromParagraphsToValue( paragraphs )
} )
} />
<footer>
<Editable
value={ citation }
onChange={
( newValue ) => setAttributes( {
citation: newValue
} )
} />
</footer>
}
focus={ focus && focus.editable === 'value' ? focus : null }
onFocus={ () => updateFocus( { editable: 'value' } ) }
/>
{ ( citation || !! focus ) &&
<footer>
<Editable
value={ citation }
onChange={
( newValue ) => setAttributes( {
citation: newValue
} )
}
focus={ focus && focus.editable === 'citation' ? focus : null }
onFocus={ () => updateFocus( { editable: 'citation' } ) }
/>
</footer>
}
</blockquote>
);
},
Expand Down