@khanacademy/wonder-blocks-button
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -29,5 +29,5 @@ // @flow | ||
const StyledAnchor = addStyle("a"); | ||
const StyledButton = addStyle("button"); | ||
const StyledLink = addStyle(Link); | ||
const StyledAnchor = addStyle<"a">("a"); | ||
const StyledButton = addStyle<"button">("button"); | ||
const StyledLink = addStyle<typeof Link>(Link); | ||
@@ -127,3 +127,3 @@ export default class ButtonCore extends React.Component<Props> { | ||
if (href) { | ||
if (href && !disabled) { | ||
return router && !skipClientNav ? ( | ||
@@ -130,0 +130,0 @@ <StyledLink {...commonProps} to={href}> |
@@ -106,3 +106,3 @@ There are three `kind`s of buttons: `"primary"` (default), `"secondary"`, and | ||
style={styles.button} | ||
onClick={(e) => window.alert("Hello, world!")} | ||
href={"/foo"} | ||
kind="secondary" | ||
@@ -109,0 +109,0 @@ disabled={true} |
@@ -87,2 +87,26 @@ // @flow | ||
}); | ||
test("disallow navigation when href and disabled are both set", () => { | ||
const wrapper = mount( | ||
<MemoryRouter> | ||
<div> | ||
<Button testId="button" href="/foo" disabled={true}> | ||
Click me! | ||
</Button> | ||
<Switch> | ||
<Route path="/foo"> | ||
<div id="foo">Hello, world!</div> | ||
</Route> | ||
</Switch> | ||
</div> | ||
</MemoryRouter>, | ||
); | ||
// Act | ||
const buttonWrapper = wrapper.find(`[data-test-id="button"]`).first(); | ||
buttonWrapper.simulate("click", {button: 0}); | ||
// Assert | ||
expect(wrapper.find("#foo").exists()).toBe(false); | ||
}); | ||
}); |
@@ -241,3 +241,3 @@ import { createElement, Component, Fragment } from 'react'; | ||
if (href) { | ||
if (href && !disabled) { | ||
return router && !skipClientNav ? createElement(StyledLink, _extends({}, commonProps, { | ||
@@ -244,0 +244,0 @@ to: href |
@@ -300,3 +300,3 @@ module.exports = | ||
if (href) { | ||
if (href && !disabled) { | ||
return router && !skipClientNav ? external_react_["createElement"](StyledLink, _extends({}, commonProps, { | ||
@@ -303,0 +303,0 @@ to: href |
@@ -121,3 +121,3 @@ // This file is auto-generated by gen-snapshot-tests.js | ||
style={styles.button} | ||
onClick={(e) => window.alert("Hello, world!")} | ||
href={"/foo"} | ||
kind="secondary" | ||
@@ -124,0 +124,0 @@ disabled={true} |
{ | ||
"name": "@khanacademy/wonder-blocks-button", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"design": "v1", | ||
@@ -18,8 +18,8 @@ "publishConfig": { | ||
"dependencies": { | ||
"@khanacademy/wonder-blocks-color": "^1.0.13", | ||
"@khanacademy/wonder-blocks-core": "^1.2.6", | ||
"@khanacademy/wonder-blocks-icon": "^1.0.11", | ||
"@khanacademy/wonder-blocks-progress-spinner": "^1.0.10", | ||
"@khanacademy/wonder-blocks-spacing": "^2.0.11", | ||
"@khanacademy/wonder-blocks-typography": "^1.0.13" | ||
"@khanacademy/wonder-blocks-color": "^1.0.14", | ||
"@khanacademy/wonder-blocks-core": "^1.2.7", | ||
"@khanacademy/wonder-blocks-icon": "^1.0.12", | ||
"@khanacademy/wonder-blocks-progress-spinner": "^1.0.11", | ||
"@khanacademy/wonder-blocks-spacing": "^2.0.12", | ||
"@khanacademy/wonder-blocks-typography": "^1.0.14" | ||
}, | ||
@@ -26,0 +26,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
378256
16
2207