From 8d40ed773b08575a6d8345e116049203e204fa43 Mon Sep 17 00:00:00 2001 From: Florian Fuchs Date: Wed, 8 Mar 2017 15:03:38 +0100 Subject: [PATCH] Fix nodes actions toolbar An additional span inside the nodes toolbar, added by the i18n FormattedMessage component, breaks the toolbar by changing the click event target to the span element; because the span element doesn't contain the "name" attribute needed to determine the appropriate action. This patch adds a small method to lookup the closest name attribute (either on the element or the parent elements), so both buttons with and without a FormattedMessage of them will work. Change-Id: I7c565da8bf2f5040ff99b13f02cb0a7f4c07637f Closes-Bug: #1671100 --- releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml | 5 +++++ src/js/components/nodes/RegisteredNodesTabPane.js | 3 ++- src/js/components/utils/Dom.js | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml create mode 100644 src/js/components/utils/Dom.js diff --git a/releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml b/releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml new file mode 100644 index 00000000..d0a66b85 --- /dev/null +++ b/releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml @@ -0,0 +1,5 @@ +fixes: + - | + Fixes `bug 1671100 `__ + Fixes a bug in the nodes table toolbar which made the introspect and + provide buttons unclickable diff --git a/src/js/components/nodes/RegisteredNodesTabPane.js b/src/js/components/nodes/RegisteredNodesTabPane.js index 4474e20f..0ff96c4a 100644 --- a/src/js/components/nodes/RegisteredNodesTabPane.js +++ b/src/js/components/nodes/RegisteredNodesTabPane.js @@ -15,6 +15,7 @@ import FormErrorList from '../ui/forms/FormErrorList'; import NodesActions from '../../actions/NodesActions'; import NodesTable from './NodesTable'; import TagNodesModal from './tag_nodes/TagNodesModal'; +import { findClosestWithAttribute } from '../utils/Dom'; const messages = defineMessages({ introspectNodes: { @@ -126,7 +127,7 @@ class RegisteredNodesTabPane extends React.Component { multipleSubmit(e) { this.setState({ - submitType: e.target.name + submitType: findClosestWithAttribute(e.target, 'name') }, this.refs.registeredNodesTableForm.submit); } diff --git a/src/js/components/utils/Dom.js b/src/js/components/utils/Dom.js new file mode 100644 index 00000000..13c4316e --- /dev/null +++ b/src/js/components/utils/Dom.js @@ -0,0 +1,7 @@ +export function findClosestWithAttribute(element, attrName) { + // If the element has a name attr, return it. + // Otherwise try the parent element. + if(element) { + return element[attrName] || findClosestWithAttribute(element.parentElement, attrName); + } +}