Skip to content

Commit

Permalink
Revert "[core] fix(TagInput): restore type signature of onRemove prop (
Browse files Browse the repository at this point in the history
…#4350)"

This reverts commit be7e912.
  • Loading branch information
adidahiya authored Oct 15, 2020
1 parent 2981d80 commit f4313f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/components/tag-input/tagInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface ITagInputProps extends IIntentProps, IProps {
* Callback invoked when the user clicks the X button on a tag.
* Receives value and index of removed tag.
*/
onRemove?: (valueAsString: string, index: number, value: React.ReactNode) => void;
onRemove?: (value: React.ReactNode, index: number) => void;

/**
* Input placeholder text which will not appear if `values` contains any items
Expand Down Expand Up @@ -466,7 +466,7 @@ export class TagInput extends AbstractPureComponent2<ITagInputProps, ITagInputSt
/** Remove the item at the given index by invoking `onRemove` and `onChange` accordingly. */
private removeIndexFromValues(index: number) {
const { onChange, onRemove, values } = this.props;
onRemove?.(values[index]?.toString() ?? "", index, values[index]);
onRemove?.(values[index], index);
if (Utils.isFunction(onChange)) {
onChange(values.filter((_, i) => i !== index));
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/test/tag-input/tagInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("<TagInput>", () => {
const wrapper = mount(<TagInput onRemove={onRemove} values={VALUES} />);
wrapper.find("button").at(1).simulate("click");
assert.isTrue(onRemove.calledOnce);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1, VALUES[1]]);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1]);
});

describe("onAdd", () => {
Expand Down Expand Up @@ -294,7 +294,7 @@ describe("<TagInput>", () => {
assert.equal(wrapper.state("activeIndex"), VALUES.length - 2);
assert.isTrue(onRemove.calledOnce);
const lastIndex = VALUES.length - 1;
assert.sameMembers(onRemove.args[0], [VALUES[lastIndex], lastIndex, VALUES[lastIndex]]);
assert.sameMembers(onRemove.args[0], [VALUES[lastIndex], lastIndex]);
});

it("pressing left arrow key navigates active item and backspace removes it", () => {
Expand All @@ -309,7 +309,7 @@ describe("<TagInput>", () => {

assert.equal(wrapper.state("activeIndex"), 0);
assert.isTrue(onRemove.calledOnce);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1, VALUES[1]]);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1]);
});

it("pressing left arrow key navigates active item and delete removes it", () => {
Expand All @@ -326,7 +326,7 @@ describe("<TagInput>", () => {
// we rather "take the place" of the item we just removed
assert.equal(wrapper.state("activeIndex"), 1);
assert.isTrue(onRemove.calledOnce);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1, VALUES[1]]);
assert.sameMembers(onRemove.args[0], [VALUES[1], 1]);
});

it("pressing delete with no selection does nothing", () => {
Expand Down

0 comments on commit f4313f0

Please sign in to comment.