Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default [
'**/css',
'packages/react-core/src/helpers/Popper/thirdparty',
'packages/react-docs/patternfly-docs/generated',
'packages/react-docs/coverage',
'.history/*',
'packages/react-docs/static',
'**/.cache'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,14 @@ class CodeEditor extends React.Component<CodeEditorProps, CodeEditorState> {
>
{editorHeader}
<div className={css(styles.codeEditorMain, isDragActive && styles.modifiers.dragHover)}>
<div className={css(styles.codeEditorUpload)}>
<input {...getInputProps()} /* hidden, necessary for react-dropzone */ hidden />
{(showEmptyState || providedEmptyState) && !value ? emptyState : editor}
</div>
{(showEmptyState || providedEmptyState) && !value ? (
<div className={css(styles.codeEditorUpload)}>
<input {...getInputProps()} /* hidden, necessary for react-dropzone */ hidden />
{emptyState}
</div>
) : (
editor
)}
</div>
</div>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ test('Matches snapshot with control buttons enabled', () => {
expect(asFragment()).toMatchSnapshot();
});

test(`Renders with default classes ${styles.codeEditor}, ${styles.codeEditorMain}, ${styles.codeEditorCode}`, () => {
test(`Renders with default classes ${styles.codeEditor}, ${styles.codeEditorCode}`, () => {
render(<CodeEditor />);
expect(screen.getByTestId('mock-editor').parentElement).toHaveClass(styles.codeEditorCode);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement).toHaveClass(styles.codeEditorMain);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement?.parentElement).toHaveClass(styles.codeEditor);
});

Expand All @@ -34,9 +33,9 @@ test(`Renders with ${styles.modifiers.readOnly} when isReadOnly = true`, () => {
);
});

test(`Renders with ${styles.codeEditorUpload} when isUploadEnabled = true`, () => {
test(`Renders with ${styles.codeEditorMain} when isUploadEnabled = true`, () => {
render(<CodeEditor isUploadEnabled code="test" />);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement).toHaveClass(styles.codeEditorUpload);
expect(screen.getByTestId('mock-editor').parentElement?.parentElement).toHaveClass(styles.codeEditorMain);
});

test(`Renders with empty state when code = undefined`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,13 @@ exports[`Matches snapshot with control buttons enabled 1`] = `
class="pf-v6-c-code-editor__main"
>
<div
class="pf-v6-c-code-editor__upload"
class="pf-v6-c-code-editor__code"
dir="ltr"
tabindex="0"
>
<input
hidden=""
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); height: 1px; margin: 0px -1px -1px 0px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap;"
tabindex="-1"
type="file"
/>
<div
class="pf-v6-c-code-editor__code"
dir="ltr"
tabindex="0"
>
<div
data-testid="mock-editor"
/>
</div>
data-testid="mock-editor"
/>
</div>
</div>
</div>
Expand Down
Loading