Commit 4ea882ce authored by Yura Zenevich's avatar Yura Zenevich
Browse files

Bug 1424159 - make trees in console keyboard accessible. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D21546

--HG--
extra : moz-landing-system : lando
parent dfc5f06e
......@@ -168,6 +168,7 @@ class TreeNode extends Component {
item: _propTypes2.default.any.isRequired,
isExpandable: _propTypes2.default.bool.isRequired,
onClick: _propTypes2.default.func,
shouldItemUpdate: _propTypes2.default.func,
renderItem: _propTypes2.default.func.isRequired
};
}
......@@ -196,7 +197,7 @@ class TreeNode extends Component {
}
shouldComponentUpdate(nextProps) {
return this.props.item !== nextProps.item || this.props.focused !== nextProps.focused || this.props.expanded !== nextProps.expanded;
return this.props.item !== nextProps.item || (this.props.shouldItemUpdate && this.props.shouldItemUpdate(this.props.item, nextProps.item)) || this.props.focused !== nextProps.focused || this.props.expanded !== nextProps.expanded;
}
/**
......@@ -423,6 +424,17 @@ class Tree extends Component {
// getChildren: item => item.children
getChildren: _propTypes2.default.func.isRequired,
// A function to check if the tree node for the item should be updated.
//
// Type: shouldItemUpdate(prevItem: Item, nextItem: Item) -> Boolean
//
// Example:
//
// // This item should be updated if it's type is a long string
// shouldItemUpdate: (prevItem, nextItem) =>
// nextItem.type === "longstring"
shouldItemUpdate: _propTypes2.default.func,
// A function which takes an item and ArrowExpander component instance and
// returns a component, or text, or anything else that React considers
// renderable.
......@@ -993,6 +1005,7 @@ class Tree extends Component {
index: i,
item,
depth,
shouldItemUpdate: this.props.shouldItemUpdate,
renderItem: this.props.renderItem,
focused: focused === item,
active: active === item,
......@@ -3591,6 +3604,7 @@ const {
getChildrenWithEvaluations,
getActor,
getParent,
getValue,
nodeIsPrimitive,
nodeHasGetter,
nodeHasSetter
......@@ -3814,6 +3828,7 @@ class ObjectInspector extends Component {
onFocus: focusable ? this.focusItem : null,
onActivate: focusable ? this.activateItem : null,
shouldItemUpdate,
renderItem: (item, depth, focused, arrow, expanded) => ObjectInspectorItem({
...this.props,
item,
......@@ -3827,6 +3842,11 @@ class ObjectInspector extends Component {
}
}
function shouldItemUpdate(prevItem, nextItem) {
const value = getValue(nextItem);
return value && value.type === "longString";
}
function mapStateToProps(state, props) {
return {
expandedPaths: selectors.getExpandedPaths(state),
......
......@@ -63,10 +63,6 @@ function GripMessageBody(props) {
autoExpandDepth: shouldAutoExpandObjectInspector(props) ? 1 : 0,
mode,
maybeScrollToBottom,
// TODO: we disable focus since the tabbing trail is a bit weird in the output (e.g.
// location links are not focused). Let's remove the property below when we found and
// fixed the issue (See Bug 1456060).
focusable: false,
onCmdCtrlClick: (node, { depth, event, focused, expanded }) => {
const value = utils.node.getValue(node);
if (value) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment