Skip to content

Commit

Permalink
Rich Text: Remove active format in all cases for removeFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 10, 2019
1 parent c8c5ed4 commit c4ebe80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/rich-text/src/remove-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ export function removeFormat(
filterFormats( newFormats, endIndex, formatType );
endIndex++;
}
} else {
return {
...value,
activeFormats: reject( activeFormats, { type: formatType } ),
};
}
} else {
for ( let i = startIndex; i < endIndex; i++ ) {
Expand All @@ -62,7 +57,11 @@ export function removeFormat(
}
}

return normaliseFormats( { ...value, formats: newFormats } );
return normaliseFormats( {
...value,
formats: newFormats,
activeFormats: reject( activeFormats, { type: formatType } ),
} );
}

function filterFormats( formats, index, formatType ) {
Expand Down
2 changes: 2 additions & 0 deletions packages/rich-text/src/test/remove-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe( 'removeFormat', () => {
};
const expected = {
formats: [ , , , , [ em ], [ em ], [ em ], , , , , , , ],
activeFormats: [],
text: 'one two three',
};
const result = removeFormat( deepFreeze( record ), 'strong', 3, 6 );
Expand All @@ -37,6 +38,7 @@ describe( 'removeFormat', () => {
};
const expected = {
formats: [ , , , , [ em ], [ em ], [ em ], , , , , , , ],
activeFormats: [],
text: 'one two three',
};
const result = removeFormat( deepFreeze( record ), 'strong', 4, 4 );
Expand Down

0 comments on commit c4ebe80

Please sign in to comment.