Skip to content

Commit

Permalink
[table] fix(EditableCell): support tabIndex prop correctly (#3687)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmoyopenroot authored and adidahiya committed Aug 19, 2019
1 parent 659034c commit 3632e68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/table/src/cell/editableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ export class EditableCell extends React.Component<IEditableCellProps, IEditableC
}

public renderHotkeys() {
const { tabIndex } = this.props;

return (
<Hotkeys>
<Hotkeys tabIndex={tabIndex}>
<Hotkey
key="edit-cell"
label="Edit the currently focused cell"
Expand Down
18 changes: 17 additions & 1 deletion packages/table/test/editableCellTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as sinon from "sinon";

import { Classes } from "@blueprintjs/core";
import * as TableClasses from "../src/common/classes";
import { EditableCell } from "../src/index";
import { Cell, EditableCell } from "../src/index";
import { CellType, expectCellLoading } from "./cellTestUtils";

describe("<EditableCell>", () => {
Expand All @@ -35,6 +35,22 @@ describe("<EditableCell>", () => {
expectCellLoading(editableCellHarness.first().getDOMNode(), CellType.BODY_CELL);
});

it("renders cell with default tabIndex as zero", () => {
const tabIndex = 0;
const elem = mount(<EditableCell value="test-value-5000" />);
const cellInstance = elem.find(Cell).instance() as Cell;

expect(cellInstance.props.tabIndex).to.equal(tabIndex);
});

it("renders cell with tabIndex", () => {
const tabIndex = 1;
const elem = mount(<EditableCell tabIndex={tabIndex} value="test-value-5000" />);
const cellInstance = elem.find(Cell).instance() as Cell;

expect(cellInstance.props.tabIndex).to.equal(tabIndex);
});

it("renders new value if props.value changes", () => {
const VALUE_1 = "foo";
const VALUE_2 = "bar";
Expand Down

1 comment on commit 3632e68

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[table] fix(EditableCell): support tabIndex prop correctly (#3687)

Previews: documentation | landing | table

Please sign in to comment.