Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions airflow/www/static/js/components/RenderedJsonField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React from "react";
import React, { useEffect } from "react";

import ReactJson, { ReactJsonViewProps } from "react-json-view";

Expand All @@ -39,9 +39,17 @@ interface Props extends FlexProps {

const RenderedJsonField = ({ content, jsonProps, ...rest }: Props) => {
const [isJson, contentJson, contentFormatted] = jsonParse(content);
const { onCopy, hasCopied } = useClipboard(contentFormatted);
const { onCopy, hasCopied, setValue } = useClipboard(contentFormatted);
const theme = useTheme();

// Current version of the "@chakra-ui/hooks v2.1.2" have a problem with multiple different run configs.
// The following code piece derived from this issue: https://github.com/chakra-ui/chakra-ui/issues/6759
useEffect(() => {
if (contentFormatted) {
setValue(contentFormatted);
}
}, [contentFormatted, setValue]);

return isJson ? (
<Flex {...rest} p={2}>
<ReactJson
Expand Down
Loading