From 8409875d8ea4cdc1f9fa49db34ec1bbb72b1f61a Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Tue, 12 Jul 2016 08:20:47 -0400 Subject: [PATCH] [fixed] buttons submitting forms fixes #416 --- src/{WidgetButton.jsx => Button.jsx} | 12 ++++++++++-- src/DateTimePicker.jsx | 2 +- src/Footer.jsx | 2 +- src/Header.jsx | 2 +- src/NumberPicker.jsx | 2 +- src/Select.js | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) rename src/{WidgetButton.jsx => Button.jsx} (82%) diff --git a/src/WidgetButton.jsx b/src/Button.jsx similarity index 82% rename from src/WidgetButton.jsx rename to src/Button.jsx index f323a7d52..678391533 100644 --- a/src/WidgetButton.jsx +++ b/src/Button.jsx @@ -1,7 +1,7 @@ import React from 'react'; import cn from 'classnames'; -export default React.createClass({ +class Button extends React.Component { render() { let { @@ -15,11 +15,17 @@ export default React.createClass({ , component: Tag = 'button' , ...props } = this.props; + let type = props.type; + + if (Tag === 'button') + type = type || 'button'; + return ( ) } -}) +} + +export default Button; diff --git a/src/DateTimePicker.jsx b/src/DateTimePicker.jsx index c34764fe5..b957ac9c4 100644 --- a/src/DateTimePicker.jsx +++ b/src/DateTimePicker.jsx @@ -16,7 +16,7 @@ import Popup from './Popup'; import BaseCalendar from './Calendar'; import TimeList from './TimeList'; import DateTimePickerInput from './DateTimePickerInput'; -import Button from './WidgetButton'; +import Button from './Button'; import CustomPropTypes from './util/propTypes'; import createUncontrolledWidget from 'uncontrollable'; import { widgetEditable } from './util/interaction'; diff --git a/src/Footer.jsx b/src/Footer.jsx index 4e31e5fc5..c922a74ec 100644 --- a/src/Footer.jsx +++ b/src/Footer.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import Button from './WidgetButton'; +import Button from './Button'; import { date as dateLocalizer } from './util/localizers'; var format = props => dateLocalizer.getFormat('footer', props.format) diff --git a/src/Header.jsx b/src/Header.jsx index 9f90dd159..963ddd7b4 100644 --- a/src/Header.jsx +++ b/src/Header.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import Button from './WidgetButton'; +import Button from './Button'; export default React.createClass({ displayName: 'Header', diff --git a/src/NumberPicker.jsx b/src/NumberPicker.jsx index eb8d15e69..d9433ab46 100644 --- a/src/NumberPicker.jsx +++ b/src/NumberPicker.jsx @@ -8,7 +8,7 @@ import { directions } from './util/constants'; import repeater from './util/repeater'; import { number as numberLocalizer } from './util/localizers'; import Input from './NumberInput'; -import Button from './WidgetButton'; +import Button from './Button'; import { widgetEditable } from './util/interaction'; import { notify } from './util/widgetHelpers'; diff --git a/src/Select.js b/src/Select.js index 3c9f498f8..c5015f02b 100644 --- a/src/Select.js +++ b/src/Select.js @@ -1,7 +1,7 @@ import React from 'react'; import cn from 'classnames'; -import Button from './WidgetButton'; +import Button from './Button'; class Select extends React.Component {