From 66cef71cfbcff152653cff77ed093d17d2ae69be Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 4 May 2019 21:31:52 +0200 Subject: [PATCH] feat: add support for id attribute to SubmitButton on #input --- packages/dnb-ui-lib/src/components/input/Input.js | 5 ++++- .../input/__tests__/__snapshots__/Input.test.js.snap | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/dnb-ui-lib/src/components/input/Input.js b/packages/dnb-ui-lib/src/components/input/Input.js index b8ac0aba024..d50a543b476 100644 --- a/packages/dnb-ui-lib/src/components/input/Input.js +++ b/packages/dnb-ui-lib/src/components/input/Input.js @@ -362,6 +362,7 @@ export default class Input extends PureComponent { class SubmitButton extends PureComponent { static propTypes = { + id: PropTypes.string, value: PropTypes.string, title: PropTypes.string, variant: ButtonPropTypes.variant, @@ -380,6 +381,7 @@ class SubmitButton extends PureComponent { } static defaultProps = { + id: null, value: null, title: null, disabled: false, @@ -414,9 +416,10 @@ class SubmitButton extends PureComponent { dispatchCustomElementEvent(this, 'on_submit', { value, event }) } render() { - const { title, disabled, variant, icon, icon_size } = this.props + const { id, title, disabled, variant, icon, icon_size } = this.props const params = { + id, type: 'submit', title, disabled diff --git a/packages/dnb-ui-lib/src/components/input/__tests__/__snapshots__/Input.test.js.snap b/packages/dnb-ui-lib/src/components/input/__tests__/__snapshots__/Input.test.js.snap index 54d1aa8f495..6a9724414fb 100644 --- a/packages/dnb-ui-lib/src/components/input/__tests__/__snapshots__/Input.test.js.snap +++ b/packages/dnb-ui-lib/src/components/input/__tests__/__snapshots__/Input.test.js.snap @@ -48,6 +48,7 @@ exports[`Input component have to match type="search" snapshot 1`] = ` "disabled": "disabled", "icon": "icon", "icon_size": "icon_size", + "id": "id", "on_submit": [Function], "on_submit_blur": [Function], "on_submit_focus": [Function], @@ -157,6 +158,7 @@ exports[`Input component have to match type="search" snapshot 1`] = ` "disabled": "disabled", "icon": "icon", "icon_size": "icon_size", + "id": "id", "on_submit": [Function], "on_submit_blur": [Function], "on_submit_focus": [Function], @@ -218,7 +220,7 @@ exports[`Input component have to match type="search" snapshot 1`] = ` icon="search" icon_position="right" icon_size="default" - id={null} + id="input" innerRef={null} onBlur={[Function]} onClick={[Function]} @@ -231,7 +233,8 @@ exports[`Input component have to match type="search" snapshot 1`] = ` variant="secondary" >