Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Double-clicking watch expression values causes editing #8013

Closed
wants to merge 7 commits into from

Conversation

@lawrencek0
Copy link

@lawrencek0 lawrencek0 commented Feb 21, 2019

Fixes #7867

Summary of Changes

  • Moved the function editExpression to ObjectInspector to pass it to ObjectInspectorItem
  • Added a depth check to make sure that double clicking properties does not cause editing
@jaril
Copy link
Contributor

@jaril jaril commented Feb 22, 2019

Ran this to double check.

On a primitive, double-clicking the node highlights the label + delimiter + value. There's an unrelated node highlighting behavior (#8019) that hides the actual text selection, but I can paste it onto the URL bar in the example below. Double-clicking the label edits as expected.

feb-22-2019 11-17-46

On an object, double clicking the node registers as a click first which expands the node, and then on the second click it moves on to edit the label/expression. It ignores depth > 0 nodes properly so clicking on properties doesn't prompt an edit.

feb-22-2019 11-19-27

@darkwing darkwing self-assigned this Feb 28, 2019
@lawrencek0
Copy link
Author

@lawrencek0 lawrencek0 commented Mar 1, 2019

Thanks for testing it out @jaril. One thing I noticed while using Chrome's DevTools is that double clicking anywhere on the expression block causes editing while on Firefox it does not work on the edge of the expression.
Firefox Dev Tools Behavior
Chrome Dev Tools Behavior

@darkwing
Copy link
Contributor

@darkwing darkwing commented Mar 5, 2019

I just pushed a rebase of this branch which hopefully fixes circle

@darkwing
Copy link
Contributor

@darkwing darkwing commented Apr 25, 2019

How does this look @nchevobbe ?

@nchevobbe
Copy link
Member

@nchevobbe nchevobbe commented Apr 26, 2019

code wise it feels fine, but playing with it, it's a bit weird.
Is this only fixing the issue of double clicking on a node from an expanded object?
Also, we lose some affordance, as clicking on the right of the expression result won't edit the expression.
Maybe we could keep the onDoubleClick on the <li>, and check the event target to see if it's not a "child" node?

diff --git a/devtools/client/debugger/src/components/SecondaryPanes/Expressions.js b/devtools/client/debugger/src/components/SecondaryPanes/Expressions.js
--- a/devtools/client/debugger/src/components/SecondaryPanes/Expressions.js
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Expressions.js
@@ -257,9 +257,13 @@ class Expressions extends Component<Prop
         className="expression-container"
         key={input}
         title={expression.input}
-        onDoubleClick={(items, options) =>
-          this.editExpression(expression, index)
-        }
+        onDoubleClick={e => {
+          const treeNode = e.target.closest(".tree-node");
+          const level = treeNode && parseInt(treeNode.getAttribute("aria-level"));
+          if (!treeNode || level === 1) {
+            this.editExpression(expression, index)
+          }
+        }}
       >
         <div className="expression-content">
           <ObjectInspector
@lawrencek0
Copy link
Author

@lawrencek0 lawrencek0 commented May 16, 2019

Yes, that does feel a bit weird. What do you think @darkwing? Should I change my PR to accommodate that?

@darkwing
Copy link
Contributor

@darkwing darkwing commented May 29, 2019

Yes, I love @nchevobbe 's idea!

@lawrencek0
Copy link
Author

@lawrencek0 lawrencek0 commented Jun 4, 2019

Great @darkwing! I will push the changes as soon as I get back!

@lawrencek0
Copy link
Author

@lawrencek0 lawrencek0 commented Nov 25, 2020

I was away from GitHub. Apologies for not closing it in time!

@lawrencek0 lawrencek0 closed this Nov 25, 2020
@lawrencek0 lawrencek0 deleted the lawrencek0:dblclick-edit-value branch Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants