Skip to content

Commit 8733cc5

Browse files
Ensuring that titles are stripped of HTML when grabbed
1 parent b9c312d commit 8733cc5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

components/content-picker/SortableList.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import styled from '@emotion/styled';
2020
import PickedItem, { PickedItemType } from './PickedItem';
2121
import { DraggableChip } from './DraggableChip';
2222
import { ContentSearchMode } from '../content-search/types';
23+
import { toPlainTextTitle } from '../content-search/utils';
2324

2425
const dropAnimation = {
2526
...defaultDropAnimation,
@@ -123,7 +124,7 @@ const SortableList: React.FC<SortableListProps> = ({
123124
if (mode === 'post') {
124125
const post = result as Post;
125126
newItem = {
126-
title: post.title.rendered,
127+
title: toPlainTextTitle(post.title.rendered),
127128
url: post.link,
128129
id: post.id,
129130
type: post.type,
@@ -132,15 +133,15 @@ const SortableList: React.FC<SortableListProps> = ({
132133
} else if (mode === 'user') {
133134
const user = result as User;
134135
newItem = {
135-
title: user.name,
136+
title: toPlainTextTitle(user.name),
136137
url: user.link,
137138
id: user.id,
138139
type: 'user',
139140
};
140141
} else {
141142
const taxonomy = result as Term;
142143
newItem = {
143-
title: taxonomy.name,
144+
title: toPlainTextTitle(taxonomy.name),
144145
url: taxonomy.link,
145146
id: taxonomy.id,
146147
type: taxonomy.taxonomy,

components/content-search/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const normalizeResults = ({
124124
return {
125125
id: userItem.id,
126126
subtype: mode,
127-
title: userItem.name,
127+
title: toPlainTextTitle(userItem.name),
128128
type: mode,
129129
url: userItem.link,
130130
};
@@ -133,7 +133,7 @@ export const normalizeResults = ({
133133
return {
134134
id: searchItem.id as number,
135135
subtype: searchItem.subtype,
136-
title: searchItem.title,
136+
title: toPlainTextTitle(searchItem.title),
137137
type: searchItem.type,
138138
url: searchItem.url,
139139
};

0 commit comments

Comments
 (0)