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
This commit is contained in:
Florian Fuchs 2017-03-08 15:03:38 +01:00
parent 01db9d5ab7
commit 8d40ed773b
3 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,5 @@
fixes:
- |
Fixes `bug 1671100 <https://launchpad.net/bugs/1671100>`__
Fixes a bug in the nodes table toolbar which made the introspect and
provide buttons unclickable

View File

@ -15,6 +15,7 @@ import FormErrorList from '../ui/forms/FormErrorList';
import NodesActions from '../../actions/NodesActions'; import NodesActions from '../../actions/NodesActions';
import NodesTable from './NodesTable'; import NodesTable from './NodesTable';
import TagNodesModal from './tag_nodes/TagNodesModal'; import TagNodesModal from './tag_nodes/TagNodesModal';
import { findClosestWithAttribute } from '../utils/Dom';
const messages = defineMessages({ const messages = defineMessages({
introspectNodes: { introspectNodes: {
@ -126,7 +127,7 @@ class RegisteredNodesTabPane extends React.Component {
multipleSubmit(e) { multipleSubmit(e) {
this.setState({ this.setState({
submitType: e.target.name submitType: findClosestWithAttribute(e.target, 'name')
}, this.refs.registeredNodesTableForm.submit); }, this.refs.registeredNodesTableForm.submit);
} }

View File

@ -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);
}
}