Skip to content

Commit

Permalink
Remove isRawAttribute from saveEntityRecord – the logic is deceivingl…
Browse files Browse the repository at this point in the history
…y similar, but is about including specific attributes regardless of their "raw-ness"
  • Loading branch information
adamziel committed Sep 2, 2021
1 parent 36da4f0 commit b28f032
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';
import { createBatch } from './batch';
import { getDispatch } from './controls';
import { STORE_NAME } from './name';
import { isRawAttribute } from './utils';

/**
* Returns an action object used in signalling that authors have been received.
Expand Down Expand Up @@ -423,7 +422,9 @@ export const saveEntityRecord = (
let data = { ...persistedRecord, ...autosavePost, ...record };
data = Object.keys( data ).reduce(
( acc, key ) => {
if ( isRawAttribute( entity, key ) ) {
if (
[ 'title', 'excerpt', 'content' ].includes( key )
) {
// Edits should be the "raw" attribute values.
acc[ key ] = get( data[ key ], 'raw', data[ key ] );
}
Expand Down Expand Up @@ -455,7 +456,11 @@ export const saveEntityRecord = (
newRecord = Object.keys( newRecord ).reduce(
( acc, key ) => {
// These properties are persisted in autosaves.
if ( isRawAttribute( entity, key ) ) {
if (
[ 'title', 'excerpt', 'content' ].includes(
key
)
) {
// Edits should be the "raw" attribute values.
acc[ key ] = get(
newRecord[ key ],
Expand Down

0 comments on commit b28f032

Please sign in to comment.