@contentful/field-editor-slug 2.2.3-canary.0 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -304,7 +304,7 @@ describe('SlugEditor', ()=>{
|
|
|
304
304
|
expect(getByTestId('cf-ui-text-input')).not.toHaveAttribute('aria-invalid');
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
|
-
it('
|
|
307
|
+
it('hides duplicate warning when publish sets hasError', async ()=>{
|
|
308
308
|
const performUniqueCheck = jest.fn().mockResolvedValue(false);
|
|
309
309
|
const setValue = jest.fn();
|
|
310
310
|
const { queryByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_SlugEditorField.SlugEditorFieldStatic, {
|
|
@@ -320,8 +320,8 @@ describe('SlugEditor', ()=>{
|
|
|
320
320
|
performUniqueCheck: performUniqueCheck
|
|
321
321
|
}));
|
|
322
322
|
await (0, _react1.waitFor)(()=>{
|
|
323
|
-
expect(queryByTestId('slug-editor-duplicate-error')).toBeInTheDocument();
|
|
324
323
|
expect(queryByTestId('slug-editor-duplicate-warning')).not.toBeInTheDocument();
|
|
324
|
+
expect(queryByTestId('slug-editor-duplicate-error')).not.toBeInTheDocument();
|
|
325
325
|
});
|
|
326
326
|
});
|
|
327
327
|
});
|
|
@@ -114,8 +114,8 @@ function SlugEditorFieldStatic(props) {
|
|
|
114
114
|
const { hasError, isDisabled, value, setValue, onChange, onBlur, isUniqueValidationEnabled, id } = props;
|
|
115
115
|
const status = useUniqueChecker(props);
|
|
116
116
|
const hasDuplicate = status === 'duplicate';
|
|
117
|
-
const shouldShowDuplicateAsError = hasDuplicate &&
|
|
118
|
-
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError;
|
|
117
|
+
const shouldShowDuplicateAsError = hasDuplicate && isUniqueValidationEnabled && !hasError;
|
|
118
|
+
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError && !hasError;
|
|
119
119
|
return /*#__PURE__*/ _react.createElement("div", {
|
|
120
120
|
className: _styles.inputContainer
|
|
121
121
|
}, /*#__PURE__*/ _react.createElement(_f36icons.LinkSimpleIcon, {
|
|
@@ -259,7 +259,7 @@ describe('SlugEditor', ()=>{
|
|
|
259
259
|
expect(getByTestId('cf-ui-text-input')).not.toHaveAttribute('aria-invalid');
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
|
-
it('
|
|
262
|
+
it('hides duplicate warning when publish sets hasError', async ()=>{
|
|
263
263
|
const performUniqueCheck = jest.fn().mockResolvedValue(false);
|
|
264
264
|
const setValue = jest.fn();
|
|
265
265
|
const { queryByTestId } = render(/*#__PURE__*/ React.createElement(SlugEditorFieldStatic, {
|
|
@@ -275,8 +275,8 @@ describe('SlugEditor', ()=>{
|
|
|
275
275
|
performUniqueCheck: performUniqueCheck
|
|
276
276
|
}));
|
|
277
277
|
await waitFor(()=>{
|
|
278
|
-
expect(queryByTestId('slug-editor-duplicate-error')).toBeInTheDocument();
|
|
279
278
|
expect(queryByTestId('slug-editor-duplicate-warning')).not.toBeInTheDocument();
|
|
279
|
+
expect(queryByTestId('slug-editor-duplicate-error')).not.toBeInTheDocument();
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
282
|
});
|
|
@@ -55,8 +55,8 @@ export function SlugEditorFieldStatic(props) {
|
|
|
55
55
|
const { hasError, isDisabled, value, setValue, onChange, onBlur, isUniqueValidationEnabled, id } = props;
|
|
56
56
|
const status = useUniqueChecker(props);
|
|
57
57
|
const hasDuplicate = status === 'duplicate';
|
|
58
|
-
const shouldShowDuplicateAsError = hasDuplicate &&
|
|
59
|
-
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError;
|
|
58
|
+
const shouldShowDuplicateAsError = hasDuplicate && isUniqueValidationEnabled && !hasError;
|
|
59
|
+
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError && !hasError;
|
|
60
60
|
return /*#__PURE__*/ React.createElement("div", {
|
|
61
61
|
className: styles.inputContainer
|
|
62
62
|
}, /*#__PURE__*/ React.createElement(LinkSimpleIcon, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-slug",
|
|
3
|
-
"version": "2.2.3
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"registry": "https://npm.pkg.github.com/"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cefded33fb8443872aed5fd6d8a9b4f8c165a340"
|
|
63
63
|
}
|