debugger icon indicating copy to clipboard operation
debugger copied to clipboard

Conditional breakpoint panel close button is hidden in files with long lines

Open irfanhudda opened this issue 9 years ago • 10 comments

Close button of conditional breakpoint panel is hidden when viewing files with long lines.

Steps to reproduce:

  1. Open a file in debugger with long line (horizontal scrollbar in codemirror should appear)
  2. Right click on gutter and select Add Conditional Breakpoint
  3. Close button is not visible. (Can be seen if we scroll horizontally)

Screenshot

scr

This line might need some change https://github.com/devtools-html/debugger.html/blob/master/src/components/Editor/ConditionalPanel.css#L20

irfanhudda avatar Mar 05 '17 17:03 irfanhudda

I tried to find a solution for this while working on #1945, but understood from @ryanjduffy that he did not run into this working on the same fix. I am curious what the correct fix is for this.

aklt avatar Mar 06 '17 20:03 aklt

So, the problem as i understand it is that the CB panel is the width of the line and we want it to be the width of the editor wrapper... I'm open to creative solutions :P

jasonLaster avatar Mar 06 '17 20:03 jasonLaster

AFAICT there is not nice CSS solution, so something creative seems to be needed, probably a hack. Are any of you aware of an elegant solution?

aklt avatar Mar 06 '17 21:03 aklt

As far as I can tell there is no nice pure CSS way of solving this, but please let me know if I am wrong. It is possible to hook into events firing when the ConditionalPane is opened or closed and at that point programatically place the close button better.

The situation in the screenshot looks a bit more difficult to me. When dragging the SplitBox.onMove is called from Draggable and I thought there might be a good way here somewhere to get the size of the right pane and place the close button somewhere. However I don't think it is possible without refactoring the devtools-modules, something I do not feel comfortable doing.

Maybe there is another way?

aklt avatar Mar 07 '17 03:03 aklt

lets try something like this:


diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js
index e5a8cbe..6e71c33 100644
--- a/src/components/Editor/index.js
+++ b/src/components/Editor/index.js
@@ -362,9 +362,14 @@ const Editor = React.createClass({
     });

     this.cbPanel = this.editor.codeMirror.addLineWidget(line, panel, {
-      coverGutter: true
+      coverGutter: true,
+      noHScroll: true
     });
     this.cbPanel.node.querySelector("input").focus();
+
+    // set the width of the editor here...
+    const editorWidth = this.cbPanel.node.closest(".editor-pane").getBoundingClientRect().width;
+    this.cbPanel.node...;
   },

@amitzur might be interesting to you... Ultimately, i'd like to clean this up with some better react ways, but for now this is likely fine.

jasonLaster avatar Mar 07 '17 15:03 jasonLaster

I'll take a look and discuss in today's community call

On Mar 7, 2017 5:49 PM, "Jason Laster" [email protected] wrote:

lets try something like this:

diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js index e5a8cbe..6e71c33 100644--- a/src/components/Editor/index.js+++ b/src/components/Editor/index.js@@ -362,9 +362,14 @@ const Editor = React.createClass({ });

 this.cbPanel = this.editor.codeMirror.addLineWidget(line, panel, {-      coverGutter: true+      coverGutter: true,+      noHScroll: true
 });
 this.cbPanel.node.querySelector("input").focus();++    // set the width of the editor here...+    const editorWidth = this.cbPanel.node.closest(".editor-pane").getBoundingClientRect().width;+    this.cbPanel.node...;

},

@amitzur https://github.com/amitzur might be interesting to you... Ultimately, i'd like to clean this up with some better react ways, but for now this is likely fine.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/devtools-html/debugger.html/issues/2287#issuecomment-284760756, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEUAc4Pl3LveqkDY-m47KTUFGpQmmyks5rjXx4gaJpZM4MTe89 .

amitzur avatar Mar 07 '17 17:03 amitzur

Would love to join you, but I cannot make it today. curious what you find!

aklt avatar Mar 07 '17 18:03 aklt

With the patch above by @jasonLaster applied the close button will align correctly with the right pane when the conditional panel is opened. The noHScroll option was the reason for this. The situation in the image above is not fixed by this, though.

I spoke with @amitzur and found out it was concluded that the real fix, possibly involving changes to SplitBox so that resize events are emitted, will land at a later point in time. So I think the best solution for now is to apply the noHScroll part of Jasons patch.

Also, I took the liberty to add a little space between the close button and the right panel.

aklt avatar Mar 09 '17 07:03 aklt

@amitzur @aklt here's a way to always provided the dimensions to children. React cautions against context, but this might be a useful case for it.

index 74c7f48..9708f86 100644
--- a/packages/devtools-modules/client/shared/components/splitter/SplitBox.js
+++ b/packages/devtools-modules/client/shared/components/splitter/SplitBox.js
@@ -66,6 +66,13 @@ const SplitBox = React.createClass({
     };
   },

+  getChildContext() {
+    const { width, height, vert } = this.state;
+    return {
+      width, height, vert
+    };
+  },
+
   componentWillReceiveProps(nextProps) {
     if (this.props.vert !== nextProps.vert) {
       this.setState({ vert: nextProps.vert });
@@ -232,4 +239,10 @@ const SplitBox = React.createClass({
   }
 });

+SplitBox.childContextTypes = {
+  vert: PropTypes.bool,
+  width: PropTypes.number,
+  height: PropTypes.number
+};
+

jasonLaster avatar Mar 09 '17 17:03 jasonLaster

Ohh... my solution is probably impractical because we just need to tell codemirror that there was a change.

jasonLaster avatar Mar 09 '17 17:03 jasonLaster