Skip to content

Commit

Permalink
[Discover] Fix search highlighting of expanded document (#114884)
Browse files Browse the repository at this point in the history
* [Discover] fix searches highlighting of expanded document

* [Discover] apply suggestion

* [Discover] apply suggestion

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dimaanj and kibanamachine authored Oct 20, 2021
1 parent c954c3b commit 4ff3cb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export function DiscoverGridFlyout({
services,
setExpandedDoc,
}: Props) {
// Get actual hit with updated highlighted searches
const actualHit = useMemo(() => hits?.find(({ _id }) => _id === hit?._id) || hit, [hit, hits]);
const pageCount = useMemo<number>(() => (hits ? hits.length : 0), [hits]);
const activePage = useMemo<number>(() => {
const id = getDocFingerprintId(hit);
Expand Down Expand Up @@ -188,7 +190,7 @@ export function DiscoverGridFlyout({
</EuiFlyoutHeader>
<EuiFlyoutBody>
<DocViewer
hit={hit}
hit={actualHit}
columns={columns}
indexPattern={indexPattern}
filter={(mapping, value, mode) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class DocViewerTab extends React.Component<Props, State> {
shouldComponentUpdate(nextProps: Props, nextState: State) {
return (
nextProps.renderProps.hit._id !== this.props.renderProps.hit._id ||
!isEqual(nextProps.renderProps.hit.highlight, this.props.renderProps.hit.highlight) ||
nextProps.id !== this.props.id ||
!isEqual(nextProps.renderProps.columns, this.props.renderProps.columns) ||
nextState.hasError
Expand Down

0 comments on commit 4ff3cb4

Please sign in to comment.