Skip to content

Commit

Permalink
Revert "RichText: rewrite with hooks (#23132)"
Browse files Browse the repository at this point in the history
This reverts commit f15b91c.
  • Loading branch information
youknowriad committed Jun 16, 2020
1 parent cb10e2d commit bf1d105
Show file tree
Hide file tree
Showing 5 changed files with 793 additions and 735 deletions.
11 changes: 3 additions & 8 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ function RichTextWrapper(
value,
onChange,
onFocus,
editableProps,
editableTagName: TagName,
Editable,
} ) => (
<>
{ children && children( { value, onChange, onFocus } ) }
Expand All @@ -595,19 +594,15 @@ function RichTextWrapper(
isSelected={ nestedIsSelected }
>
{ ( { listBoxId, activeId, onKeyDown } ) => (
<TagName
{ ...editableProps }
<Editable
aria-autocomplete={
listBoxId ? 'list' : undefined
}
aria-owns={ listBoxId }
aria-activedescendant={ activeId }
start={ startAttr }
reversed={ reversed }
onKeyDown={ ( event ) => {
onKeyDown( event );
editableProps.onKeyDown( event );
} }
onKeyDown={ onKeyDown }
/>
) }
</Autocomplete>
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/specs/editor/various/undo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ describe( 'undo', () => {
expect( await getSelection() ).toEqual( {
blockIndex: 2,
editableIndex: 0,
startOffset: 'is'.length,
endOffset: 'is'.length,
startOffset: 0,
endOffset: 0,
} );

await pressKeyWithModifier( 'primary', 'z' ); // Undo 2nd paragraph text.
Expand All @@ -245,8 +245,8 @@ describe( 'undo', () => {
expect( await getSelection() ).toEqual( {
blockIndex: 1,
editableIndex: 0,
startOffset: 'This'.length,
endOffset: 'This'.length,
startOffset: 0,
endOffset: 0,
} );

await pressKeyWithModifier( 'primary', 'z' ); // Undo 1st paragraph text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect } from '@wordpress/element';
* Calculates and renders the format boundary style when the active formats
* change.
*/
export function useBoundaryStyle( { activeFormats, ref } ) {
export function BoundaryStyle( { activeFormats, forwardedRef } ) {
useEffect( () => {
// There's no need to recalculate the boundary styles if no formats are
// active, because no boundary styles will be visible.
Expand All @@ -16,7 +16,7 @@ export function useBoundaryStyle( { activeFormats, ref } ) {
}

const boundarySelector = '*[data-rich-text-format-boundary]';
const element = ref.current.querySelector( boundarySelector );
const element = forwardedRef.current.querySelector( boundarySelector );

if ( ! element ) {
return;
Expand Down Expand Up @@ -45,4 +45,5 @@ export function useBoundaryStyle( { activeFormats, ref } ) {
globalStyle.innerHTML = style;
}
}, [ activeFormats ] );
return null;
}
Loading

0 comments on commit bf1d105

Please sign in to comment.