From b4bded375c7a410ecdf2992205a9c6efee95368e Mon Sep 17 00:00:00 2001 From: kmcfaul <45077788+kmcfaul@users.noreply.github.com> Date: Wed, 9 Jan 2019 15:17:51 -0500 Subject: [PATCH] fix(Dropdown): set default button type to button (#1148) --- .../src/components/Dropdown/DropdownItem.js | 1 + .../src/components/Dropdown/Toggle.js | 2 ++ .../__snapshots__/Dropdown.test.js.snap | 19 +++++++++++++++++++ .../__snapshots__/DropdownItem.test.js.snap | 3 +++ .../__snapshots__/DropdownToggle.test.js.snap | 3 +++ .../__snapshots__/Toggle.test.js.snap | 2 ++ 6 files changed, 30 insertions(+) diff --git a/packages/patternfly-4/react-core/src/components/Dropdown/DropdownItem.js b/packages/patternfly-4/react-core/src/components/Dropdown/DropdownItem.js index addc6e9076d..03a60449473 100644 --- a/packages/patternfly-4/react-core/src/components/Dropdown/DropdownItem.js +++ b/packages/patternfly-4/react-core/src/components/Dropdown/DropdownItem.js @@ -37,6 +37,7 @@ const DropdownItem = ({ className, children, isHovered, component: Component, is additionalProps.tabIndex = isDisabled ? -1 : additionalProps.tabIndex; } else if (Component === 'button') { additionalProps.disabled = isDisabled; + additionalProps.type = additionalProps.type || 'button'; } return ( diff --git a/packages/patternfly-4/react-core/src/components/Dropdown/Toggle.js b/packages/patternfly-4/react-core/src/components/Dropdown/Toggle.js index 1e62c428475..b04f7f7fc41 100644 --- a/packages/patternfly-4/react-core/src/components/Dropdown/Toggle.js +++ b/packages/patternfly-4/react-core/src/components/Dropdown/Toggle.js @@ -79,6 +79,7 @@ class DropdownToggle extends Component { onToggle, parentRef, id, + type, ...props } = this.props; return ( @@ -96,6 +97,7 @@ class DropdownToggle extends Component { isPlain && styles.modifiers.plain, className )} + type={type || 'button'} onClick={_event => onToggle && onToggle(!isOpen)} aria-expanded={isOpen} > diff --git a/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/Dropdown.test.js.snap b/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/Dropdown.test.js.snap index 049b890d771..d9223e9f2d7 100644 --- a/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/Dropdown.test.js.snap +++ b/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/Dropdown.test.js.snap @@ -89,6 +89,7 @@ exports[`KebabToggle basic 1`] = ` className="pf-c-dropdown__toggle" id="Dropdown Toggle" onClick={[Function]} + type="button" > Action @@ -779,6 +784,7 @@ exports[`KebabToggle expanded 1`] = ` className="pf-m-disabled" disabled={true} href="#" + type="button" > Disabled Action @@ -840,6 +846,7 @@ exports[`KebabToggle expanded 1`] = ` className="" disabled={false} href="#" + type="button" > Separated Action @@ -994,6 +1001,7 @@ exports[`KebabToggle plain 1`] = ` className="pf-c-dropdown__toggle pf-m-plain" id="Dropdown Toggle" onClick={[Function]} + type="button" > Dropdown Dropdown Dropdown Dropdown Action @@ -2190,6 +2205,7 @@ exports[`dropdown expanded 1`] = ` className="pf-m-disabled" disabled={true} href="#" + type="button" > Disabled Action @@ -2251,6 +2267,7 @@ exports[`dropdown expanded 1`] = ` className="" disabled={false} href="#" + type="button" > Separated Action @@ -2411,6 +2428,7 @@ exports[`dropdown regular 1`] = ` className="pf-c-dropdown__toggle" id="Dropdown Toggle" onClick={[Function]} + type="button" > Dropdown Dropdown Something @@ -51,6 +52,7 @@ exports[`dropdown items disabled button 1`] = ` className="pf-m-disabled" disabled={true} href="#" + type="button" > Something @@ -83,6 +85,7 @@ exports[`dropdown items hover button 1`] = ` className="pf-m-hover" disabled={false} href="#" + type="button" > Something diff --git a/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/DropdownToggle.test.js.snap b/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/DropdownToggle.test.js.snap index f88bb1deac8..e959fc44d3f 100644 --- a/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/DropdownToggle.test.js.snap +++ b/packages/patternfly-4/react-core/src/components/Dropdown/__snapshots__/DropdownToggle.test.js.snap @@ -49,6 +49,7 @@ exports[`state active 1`] = ` className="pf-c-dropdown__toggle pf-m-active" id="Dropdown Toggle" onClick={[Function]} + type="button" > Dropdown Dropdown Dropdown Dropdown