@khanacademy/wonder-blocks-core
Advanced tools
Comparing version 2.7.0 to 2.7.1
@@ -75,2 +75,7 @@ // @flow | ||
/** | ||
* This should only be used by button.js. | ||
*/ | ||
type?: "submit", | ||
skipClientNav?: boolean, | ||
@@ -376,4 +381,7 @@ | ||
safeWithNav = undefined, | ||
href, | ||
type, | ||
} = this.props; | ||
let shouldNavigate = true; | ||
let canSubmit = true; | ||
@@ -388,7 +396,22 @@ if (onClick) { | ||
shouldNavigate = false; | ||
canSubmit = false; | ||
} | ||
// Prevent navigation. | ||
e.preventDefault(); | ||
if (!href && type === "submit" && canSubmit) { | ||
let target = e.currentTarget; | ||
while (target) { | ||
if (target instanceof window.HTMLFormElement) { | ||
const event = new window.Event("submit"); | ||
target.dispatchEvent(event); | ||
break; | ||
} | ||
// All events should be typed as SyntheticEvent<HTMLElement>. | ||
// Updating all of the places will take some time so I'll do | ||
// this later - $FlowFixMe. | ||
target = target.parentElement; | ||
} | ||
} | ||
if (beforeNav) { | ||
@@ -395,0 +418,0 @@ this.setState({waiting: true}); |
@@ -783,4 +783,7 @@ import React, { Component, createElement, createContext } from 'react'; | ||
_this$props6$safeWith = _this$props6.safeWithNav, | ||
safeWithNav = _this$props6$safeWith === void 0 ? undefined : _this$props6$safeWith; | ||
safeWithNav = _this$props6$safeWith === void 0 ? undefined : _this$props6$safeWith, | ||
href = _this$props6.href, | ||
type = _this$props6.type; | ||
var shouldNavigate = true; | ||
var canSubmit = true; | ||
@@ -795,7 +798,24 @@ if (onClick) { | ||
shouldNavigate = false; | ||
} // Prevent navigation. | ||
canSubmit = false; | ||
} | ||
e.preventDefault(); | ||
if (!href && type === "submit" && canSubmit) { | ||
var target = e.currentTarget; | ||
while (target) { | ||
if (target instanceof window.HTMLFormElement) { | ||
var event = new window.Event("submit"); | ||
target.dispatchEvent(event); | ||
break; | ||
} // All events should be typed as SyntheticEvent<HTMLElement>. | ||
// Updating all of the places will take some time so I'll do | ||
// this later - $FlowFixMe. | ||
target = target.parentElement; | ||
} | ||
} | ||
if (beforeNav) { | ||
@@ -802,0 +822,0 @@ this.setState({ |
{ | ||
"name": "@khanacademy/wonder-blocks-core", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"design": "v1", | ||
@@ -30,3 +30,3 @@ "publishConfig": { | ||
"license": "MIT", | ||
"gitHead": "483662a65071f7f5539a5a40adc9e6c22d441bf8" | ||
"gitHead": "55971121a333453523295abfe7d582071588a44e" | ||
} |
Sorry, the diff of this file is too big to display
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
377364
7722