Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use onchange instead of onClick for checkbox #35

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SuperTreeview extends Component {
<input
type="checkbox"
name={node[keywordLabel]}
onClick={(e) => {
onChange={(e) => {
this.handleCheckToggle(node, e);
}}
checked={!!node.isChecked}
Expand Down
16 changes: 8 additions & 8 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ describe('<SuperTreeview />', () => {
it('should set lastCheckToggledNodeIndex to currentNode', () => {
let setStateSpy = sandbox.spy(SuperTreeview.prototype, 'setState');

checkbox.simulate('click', { target: { checked: false } });
checkbox.simulate('change', { target: { checked: false } });

expect(setStateSpy).to.have.been.calledOnce;
});

it('should update data', () => {
checkbox.simulate('click', { target: { checked: false } });
checkbox.simulate('change', { target: { checked: false } });
expect(handleUpdateStub).to.have.been.calledOnce;
});

Expand All @@ -330,7 +330,7 @@ describe('<SuperTreeview />', () => {
let event = { target: { checked: true } };
let node = standardProps.data[0];

checkbox.simulate('click', event);
checkbox.simulate('change', event);

expect(handleCheckToggleSpy).to.have.been.calledWith(
node,
Expand All @@ -342,7 +342,7 @@ describe('<SuperTreeview />', () => {
let event = { target: { checked: false } };
let node = standardProps.data[0];

checkbox.simulate('click', event);
checkbox.simulate('change', event);

expect(handleCheckToggleSpy).to.have.been.calledWith(
node,
Expand All @@ -356,7 +356,7 @@ describe('<SuperTreeview />', () => {
let node = standardProps.data[0];
node.isChecked = event.target.checked;

checkbox.simulate('click', event);
checkbox.simulate('change', event);

expect(onCheckToggleCbStub).to.have.been.calledWith(
[node],
Expand All @@ -379,7 +379,7 @@ describe('<SuperTreeview />', () => {
});

it('should have "lastCheckToggledNodeIndex" as "number" on subsequent toggles', () => {
checkbox.simulate('click', event);
checkbox.simulate('change', event);

expect(
componentInstance.state.lastCheckToggledNodeIndex
Expand All @@ -398,7 +398,7 @@ describe('<SuperTreeview />', () => {
.find('TransitionGroup')
.childAt(3)
.find(checkboxSelector);
checkbox4.simulate('click', event);
checkbox4.simulate('change', event);
});

it('should call "onCheckToggleCbStub" once', () => {
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('<SuperTreeview />', () => {
checkbox3 = transitionGroupElement
.childAt(2)
.find(checkboxSelector);
checkbox3.simulate('click', eventUncheck);
checkbox3.simulate('change', eventUncheck);
});

it('should call "onCheckToggleCbStub" once', () => {
Expand Down