carbon-react 153.1.0 → 153.1.1

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.
@@ -63,7 +63,9 @@ export const GroupedCharacter = /*#__PURE__*/React.forwardRef(({
63
63
  newCursorPos += separatorDiff;
64
64
  } else if (isAtOneBeyondSeparator) {
65
65
  const isDeleting = value.length > rawValue.length;
66
- newCursorPos += isDeleting ? -1 : 1;
66
+ if (!isDeleting) {
67
+ newCursorPos += 1;
68
+ }
67
69
  }
68
70
  const modifiedEvent = ev;
69
71
  modifiedEvent.target = buildCustomTarget(ev, {
@@ -105,6 +107,16 @@ export const GroupedCharacter = /*#__PURE__*/React.forwardRef(({
105
107
  if (isCharacterKey && maxRawLength === value.length && !hasSelection) {
106
108
  ev.preventDefault();
107
109
  }
110
+ if (ev.key === "Delete") {
111
+ const cursorPos = selectionStart ?? /* istanbul ignore next */0;
112
+ const rawValue = sanitizeValue(value);
113
+ const formattedValue = formatValue(rawValue);
114
+ if (formattedValue[cursorPos] === separator) {
115
+ ev.preventDefault();
116
+ const target = ev.target;
117
+ setTimeout(() => target.setSelectionRange(cursorPos + 1, cursorPos + 1));
118
+ }
119
+ }
108
120
  if (onKeyDown) {
109
121
  onKeyDown(ev);
110
122
  }
@@ -72,7 +72,9 @@ const GroupedCharacter = exports.GroupedCharacter = /*#__PURE__*/_react.default.
72
72
  newCursorPos += separatorDiff;
73
73
  } else if (isAtOneBeyondSeparator) {
74
74
  const isDeleting = value.length > rawValue.length;
75
- newCursorPos += isDeleting ? -1 : 1;
75
+ if (!isDeleting) {
76
+ newCursorPos += 1;
77
+ }
76
78
  }
77
79
  const modifiedEvent = ev;
78
80
  modifiedEvent.target = buildCustomTarget(ev, {
@@ -114,6 +116,16 @@ const GroupedCharacter = exports.GroupedCharacter = /*#__PURE__*/_react.default.
114
116
  if (isCharacterKey && maxRawLength === value.length && !hasSelection) {
115
117
  ev.preventDefault();
116
118
  }
119
+ if (ev.key === "Delete") {
120
+ const cursorPos = selectionStart ?? /* istanbul ignore next */0;
121
+ const rawValue = sanitizeValue(value);
122
+ const formattedValue = formatValue(rawValue);
123
+ if (formattedValue[cursorPos] === separator) {
124
+ ev.preventDefault();
125
+ const target = ev.target;
126
+ setTimeout(() => target.setSelectionRange(cursorPos + 1, cursorPos + 1));
127
+ }
128
+ }
117
129
  if (onKeyDown) {
118
130
  onKeyDown(ev);
119
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "153.1.0",
3
+ "version": "153.1.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",