mozilla / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
176 stars 278 forks source link

Figure out why Quick Edit refuses to disappear #125

Closed puzzledShark closed 9 years ago

puzzledShark commented 9 years ago

Quick edit = Cmd + E

Presently if we expose a Tag, ID, or Class with quick edit that presently does no actually link to any local css files, when we try to close it with cmd+e it goes away for a brief second, then reappears immediately.

The colour picker is unaffected by this, it works as expected.

Extra notes: You can remove quick edit with esc, or by clicking the close button though.

AJDBenner commented 9 years ago

From my testing, quick edit only comes back immediately after closing it if there isn't any style included on the element you're doing the quick edit on.

puzzledShark commented 9 years ago

Alright with a little bit of testing I've found the general issue with why quick edit refuses to disappear. So to start I'll show off what happens in brackets presently:

brackets

In this gif you can see me Expose the p tag, then encircle where the cursor presently is, Then I expose the ol tag, then encircle where the cursor presently is.

As opposed to bramble presently, where I do the same steps: bramble

As you can see from the gif, "new rule" is not our current focus, our current focus when I expose it is in code mirror, thus when I expose again, I'm exposing from within code mirror again, thus why it disappears, and reappears.

Cmd + e will make the quick edit disappear, but if cmd + e is pressed within an element we have already exposed then it'll disappear then reappear.

TL:DR: When exposing element with no CSS applied focus is not put into the quick edit panel, it remains on the element, thus if we press it again it'll disappear then reappear.

AJDBenner commented 9 years ago

When you disable the HTMLHinter extension this issue still persists.

AJDBenner commented 9 years ago

From my research this is what is happening.

When you hit CMD + E this function is called which calls this function. When you hit CMD + E again to try and close the inline widget the call stack is the exact same as previously stated above. The closeInlineWidget function is only called when you click on the "X" on the inline widget.

AJDBenner commented 9 years ago

I've been able to narrow this issue down further. The reason CMD + E isn't closing the inline widget is because the widget doesn't have focus. The focus is in the editor.

If you click inside the widget then hit CMD + E it will close the quick edit. The desktop version of Brackets has this issue too. If you open the inline widget in desktop Brackets then click somewhere in the editor then try to hit CMD + E you can replicate this issue.

Solution: In desktop Brackets, once the inline widget is opened the focus is on the inline widget. In our version when the inline widget is opened the focus is still on the editor, not the widget. We need to give focus to the widget when CMD + E is pressed.

Here is what I mean

demo

You can see the cursor flashing in front of the "p" of the <p> tag the first time. After you click in the widget the cursor is no longer on the <p> tag and you see the "new rule" box highlight in blue.

AJDBenner commented 9 years ago

I've notice that in Bramble you aren't able to create a "new rule". I think this may be causing the issue. When you create a new CSS file then you have the option to create a "new rule" and this error doesn't occur. Here is what I mean.

demo

AJDBenner commented 9 years ago

From what I've found the issue occurs here. The disabled class is added to the New Rule button until list is known. The issue is that the disabled class is never removed here. Unfortunately, this issue isn't fixed If you manually remove the disabled class.

AJDBenner commented 9 years ago

Fixed with https://github.com/humphd/brackets-browser-livedev/pull/70

AJDBenner commented 9 years ago

This bug has been filed upstream https://github.com/adobe/brackets/issues/10975