[8.0] [data views] Improve preview pane (#126013) (#126098)

* [data views] Improve preview pane (#126013)

* fix preview pane

* fix preview pane

* one less span tag

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 7dbe341c78)

* fix test

Co-authored-by: Matthew Kime <matt@mattki.me>
This commit is contained in:
Kibana Machine 2022-02-21 16:27:22 -05:00 committed by GitHub
parent 59c4a8bcdf
commit 78b17c4280
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ import React, {
useRef,
FunctionComponent,
} from 'react';
import { renderToString } from 'react-dom/server';
import useDebounce from 'react-use/lib/useDebounce';
import { i18n } from '@kbn/i18n';
import { get } from 'lodash';
@ -107,8 +108,10 @@ const defaultParams: Params = {
format: null,
};
export const defaultValueFormatter = (value: unknown) =>
`<span>${typeof value === 'object' ? JSON.stringify(value) : value ?? '-'}</span>`;
export const defaultValueFormatter = (value: unknown) => {
const content = typeof value === 'object' ? JSON.stringify(value) : value ?? '-';
return renderToString(<>{content}</>);
};
export const FieldPreviewProvider: FunctionComponent = ({ children }) => {
const previewCount = useRef(0);