Skip to content

Commit 4632c35

Browse files
committed
update codeeditor example, update tests
1 parent 097e88e commit 4632c35

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

packages/react-code-editor/src/components/CodeEditor/examples/CodeEditor.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ propComponents: ['CodeEditor', 'CodeEditorControl', 'Popover']
88
Note: Code editor lives in its own package at [@patternfly/react-code-editor](https://www.npmjs.com/package/@patternfly/react-code-editor) and has [**required peer deps**](https://github.com/patternfly/patternfly-react/blob/main/packages/react-code-editor/package.json).
99

1010
import { CodeEditor, CodeEditorControl, Language } from '@patternfly/react-code-editor';
11-
import { Chip } from '@patternfly/react-core/deprecated';
1211
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
1312

1413
## Examples

packages/react-code-editor/src/components/CodeEditor/examples/CodeEditorShortcutMainHeader.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { CodeEditor, Language } from '@patternfly/react-code-editor';
3-
import { Grid, GridItem } from '@patternfly/react-core';
4-
import { Chip } from '@patternfly/react-core/deprecated';
3+
import { Grid, GridItem, Label } from '@patternfly/react-core';
54

65
export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
76
const onEditorDidMount = (editor, monaco) => {
@@ -40,7 +39,11 @@ export const CodeEditorShortcutMainHeader: React.FunctionComponent = () => {
4039
<React.Fragment key={index}>
4140
<GridItem style={{ textAlign: 'right', marginRight: '1em' }}>
4241
{shortcut.keys
43-
.map((key) => <Chip key={key}>{key}</Chip>)
42+
.map((key) => (
43+
<Label variant="outline" key={key}>
44+
{key}
45+
</Label>
46+
))
4447
.reduce((prev, curr) => (
4548
<>{[prev, ' + ', curr]}</>
4649
))}

packages/react-core/src/deprecated/components/Chip/Chip.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Chip extends React.Component<ChipProps> {
5050
}
5151

5252
static defaultProps: ChipProps = {
53-
closeBtnAriaLabel: 'close',
5453
className: '',
5554
isOverflowChip: false,
5655
isReadOnly: false,

packages/react-core/src/deprecated/components/Chip/__tests__/Chip.test.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,10 @@ test(`Renders actions container with class ${styles.labelActions} when isReadOnl
122122
expect(screen.getByRole('button').parentElement).toHaveClass(styles.labelActions);
123123
});
124124

125-
test(`Renders aria-labelledby on action close button by default`, () => {
126-
render(<Chip>Chip text</Chip>);
127-
128-
expect(screen.getByRole('button')).toHaveAccessibleName('close');
129-
});
130-
131-
test(`Renders aria-labelledby on action close button with custom id passed`, () => {
132-
render(<Chip id="custom-id">Chip text</Chip>);
133-
134-
expect(screen.getByRole('button')).toHaveAccessibleName('close');
135-
});
136-
137125
test(`Renders concatenated aria-label on action close button by default`, () => {
138126
render(<Chip>Chip text</Chip>);
139127

140-
expect(screen.getByRole('button')).toHaveAccessibleName('close');
128+
expect(screen.getByRole('button')).toHaveAccessibleName('Close Chip text,');
141129
});
142130

143131
test(`Renders custom aria-label on action close button when closeBtnAriaLabel is passed`, () => {
@@ -150,7 +138,7 @@ test(`Does not render close button action when isOverflowChip is true`, () => {
150138
render(<Chip isOverflowChip>Chip text</Chip>);
151139

152140
// Because overflow chip renders as a button, we need to add the accessible name to the query
153-
expect(screen.queryByRole('button', { name: 'close' })).not.toBeInTheDocument();
141+
expect(screen.queryByRole('button', { name: 'Close Chip text,' })).not.toBeInTheDocument();
154142
});
155143

156144
test(`Does not render close button action when isReadOnly is true`, () => {
@@ -181,7 +169,7 @@ test(`Calls onClick when close button action is clicked for default chip`, async
181169

182170
render(<Chip onClick={onClickMock}>Chip text</Chip>);
183171

184-
await user.click(screen.getByRole('button', { name: 'close' }));
172+
await user.click(screen.getByRole('button', { name: 'Close Chip text,' }));
185173

186174
expect(onClickMock).toHaveBeenCalledTimes(1);
187175
});

packages/react-core/src/deprecated/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ exports[`Matches snapshot 1`] = `
2424
>
2525
<button
2626
aria-disabled="false"
27-
aria-label="close"
27+
aria-label="Close Chip text,"
2828
class="pf-v5-c-button pf-m-plain"
29-
data-ouia-component-id="OUIA-Generated-Button-plain-19"
29+
data-ouia-component-id="OUIA-Generated-Button-plain-17"
3030
data-ouia-component-type="PF5/Button"
3131
data-ouia-safe="true"
3232
type="button"

0 commit comments

Comments
 (0)