Copilot commented on code in PR #37036: URL: https://github.com/apache/superset/pull/37036#discussion_r2683487298
########## superset-frontend/src/components/JsonModal/index.tsx: ########## @@ -17,32 +17,24 @@ * under the License. */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ import { FC, useMemo } from 'react'; import { JSONTree } from 'react-json-tree'; +import { styled } from '@apache-superset/core/ui'; import { useJsonTreeTheme } from 'src/hooks/useJsonTreeTheme'; import { Button, ModalTrigger } from '@superset-ui/core/components'; import { CopyToClipboard } from '../CopyToClipboard'; import { convertBigIntStrToNumber } from './utils'; import type { JsonModalProps } from './types'; +/** + * Preserve line breaks for multiline cell content (e.g. stack traces) + * while keeping the change scoped to this component only. + */ +const PreWrap = styled.pre` Review Comment: The `<pre>` element is a block-level element by default, which could cause layout issues in some contexts where JsonModal is used. For example, in ExtensionsList.tsx, the JsonModal is wrapped in a `<div>` with specific inline styling for color and text-decoration that expects inline content. Consider using `display: inline` or changing the element to a `<span>` to ensure it doesn't break inline layouts where the component is used. ```suggestion const PreWrap = styled.span` ``` ########## superset-frontend/src/components/JsonModal/index.tsx: ########## @@ -17,32 +17,24 @@ * under the License. */ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ import { FC, useMemo } from 'react'; import { JSONTree } from 'react-json-tree'; +import { styled } from '@apache-superset/core/ui'; import { useJsonTreeTheme } from 'src/hooks/useJsonTreeTheme'; import { Button, ModalTrigger } from '@superset-ui/core/components'; import { CopyToClipboard } from '../CopyToClipboard'; import { convertBigIntStrToNumber } from './utils'; import type { JsonModalProps } from './types'; +/** + * Preserve line breaks for multiline cell content (e.g. stack traces) + * while keeping the change scoped to this component only. + */ +const PreWrap = styled.pre` Review Comment: Using the `<pre>` HTML element may cause semantic and accessibility issues in this context. The `<pre>` tag is semantically intended for preformatted text blocks, not for interactive trigger elements. This could confuse screen readers and other assistive technologies. Consider using a `<span>` or `<div>` element instead with the same styling applied. This would preserve the line breaks while maintaining proper semantic HTML structure. ```suggestion const PreWrap = styled.span` ``` ########## superset-frontend/src/components/JsonModal/index.tsx: ########## @@ -74,7 +67,7 @@ export const JsonModal: FC<JsonModalProps> = ({ </Button> } modalTitle={modalTitle} - triggerNode={<>{content}</>} + triggerNode={<PreWrap>{content}</PreWrap>} Review Comment: The new behavior of preserving line breaks with `white-space: pre-wrap` lacks test coverage. While the existing tests verify that the modal renders and displays content, they don't verify that multiline text with newline characters is properly rendered with preserved line breaks in the trigger node. Consider adding a test case that passes a string with newline characters and verifies that the styling is applied correctly to the trigger element. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
