Bug 179831 - Web Inspector: Styles Redesign: pressing delete in empty value field should focus on name field
Summary: Web Inspector: Styles Redesign: pressing delete in empty value field should f...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: Safari Technology Preview
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-17 11:02 PST by Chris Chiera
Modified: 2017-12-06 16:57 PST (History)
7 users (show)

See Also:


Attachments
Patch (2.87 KB, patch)
2017-12-03 18:17 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Chiera 2017-11-17 11:02:58 PST
In Chrome if you enter say something like w and tab to auto complete, and it autocompletes something that wasn't desired you can easily clicked Delete/Backspace and it will automatically highlight that rule such as "white-space" allowing you to instantly type in a new word such as "width". In Safari Preview 44, after it autocompletes, backspace/delete does nothing. If I clicked on the word "white-space" in attempt to change it it simple deletes it all together and have to start all over again.

In older versions such as the current stable version of Safari, it works better than 44, in that backspace allows you to go back, but it just deletes the ":" and then each letter, rather than automatically deleting the ":" and automatically selecting the entire word. 

Other than a couple small bugs like this, version 44, is an incredible improvement to the inspector and resolves countless little bugs/issues in regards to editing styles/html. We all appreciate all your incredible hard work.
Comment 1 Nikita Vasilyev 2017-11-17 13:25:50 PST
The behavior I'm seeing in the new styles sidebar matches Chrome. Could you provide the exact steps to reproduce the problem? We like using this steps/actual/expected template:

Steps:
1. Add a new CSS property.
2. Type "w".
3. Press Tab.

Actual:
"white-space" property name is selected. Focus moves to property name.

Expected:
???
Comment 2 Chris Chiera 2017-11-17 13:45:41 PST
Sure thing. So in your example you mentioning simply autocompleting (which works perfectly), this is in regards to what happens when you backspace/delete after autocompleting.

So here is Safari Preview 44. On say apple.com. I add new rule and auto complete it like normal. Then I wish to change that if say it automcompleted the wrong word. Back when clicking delete, nothing happens: http://share.heavymark.com/1U3i3p0v3v0F

Now here is in Chrome stable on apple.com where it works as expected: http://share.heavymark.com/3S2R0s0v3n0t There after auto completing I can go back easily by clicking delete. 

In the current stable version of Safari it lets you go back (so, better than 44, but not as good as Chrome since it does per character rather than highlighting the whole word: http://share.heavymark.com/2P3h3p171K3c

If 44 is currently working like the chrome video above let me know and I can try reinstalling or trying on another computer. Currently using latest MBP with touchbar and latest stable version of MacOS. Hope this helps.
Comment 3 Nikita Vasilyev 2017-11-17 14:07:02 PST
I see. I didn't know that Chrome has a special case for newly added properties! If I focus on the existing property value and press delete, it doesn't move to the property name.
Comment 4 Radar WebKit Bug Importer 2017-11-17 16:28:39 PST
<rdar://problem/35626976>
Comment 5 Devin Rousso 2017-12-03 18:17:28 PST
Created attachment 328316 [details]
Patch
Comment 6 Joseph Pecoraro 2017-12-04 11:35:20 PST
Comment on attachment 328316 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328316&action=review

> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:270
> +        else if (textField === this._valueTextField)
> +            this._nameTextField.startEditing();

So Chrome's behavior is to only have backspace go from the value -> name when its a new property. I think this is so that when you start editing an existing property value and you select its contents and hit backspace, it only clears the value but doesn't also jump to the name property. What is the behavior after this patch is applied?
Comment 7 Devin Rousso 2017-12-04 12:21:15 PST
Comment on attachment 328316 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328316&action=review

>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:270
>> +            this._nameTextField.startEditing();
> 
> So Chrome's behavior is to only have backspace go from the value -> name when its a new property. I think this is so that when you start editing an existing property value and you select its contents and hit backspace, it only clears the value but doesn't also jump to the name property. What is the behavior after this patch is applied?

Interesting.  The behavior here doesn't distinguish between existing and new properties.  Personally, I find this more useful, as it allows me to delete properties a lot easier, but I could go either way.  How do you want to proceed?
Comment 8 Timothy Hatcher 2017-12-05 22:45:56 PST
Comment on attachment 328316 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328316&action=review

> Source/WebInspectorUI/ChangeLog:12
> +        * UserInterface/Views/SpreadsheetStyleProperty.js:

Oi, spreadsheet. Hmm.

>>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js:270
>>> +            this._nameTextField.startEditing();
>> 
>> So Chrome's behavior is to only have backspace go from the value -> name when its a new property. I think this is so that when you start editing an existing property value and you select its contents and hit backspace, it only clears the value but doesn't also jump to the name property. What is the behavior after this patch is applied?
> 
> Interesting.  The behavior here doesn't distinguish between existing and new properties.  Personally, I find this more useful, as it allows me to delete properties a lot easier, but I could go either way.  How do you want to proceed?

I find Chrome's behavior odd, and sounds like it could be a bug. I agree with Devin, that pressing delete enough should jump from value to name and continue editing there.
Comment 9 Timothy Hatcher 2017-12-05 22:53:20 PST
Maybe the right solution would be to allow editing existing values, pressing backspace clears and stays focused in the value, but a second backspace jumps to the name and selects it. That way if you do just want to clear the value and type a new one it works as expected, but you can get to the value too.

In my mind backspace/delete would be like a destructive reverse tab. I should be able to start at the value of the last property and holding delete, end up focused on a blank single property name after deleting through the lines of a whole rule.
Comment 10 Timothy Hatcher 2017-12-05 22:55:53 PST
Comment on attachment 328316 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328316&action=review

> Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:266
> +            if (!this.value) {

I think this does implement what I said in my last comment on how I think it should work. An initial backspace would happen when this has a value and it would just fall through and clear it as an editing operation.
Comment 11 Devin Rousso 2017-12-05 23:39:53 PST
Comment on attachment 328316 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328316&action=review

>> Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:266
>> +            if (!this.value) {
> 
> I think this does implement what I said in my last comment on how I think it should work. An initial backspace would happen when this has a value and it would just fall through and clear it as an editing operation.

Correct!  It will only jump back to the name (by calling `spreadsheetTextFieldDidBackspace`) if the editor has no content.  It would require two backspaces, the first of which to delete the existing value, to move between editors.
Comment 12 WebKit Commit Bot 2017-12-05 23:56:32 PST
Comment on attachment 328316 [details]
Patch

Clearing flags on attachment: 328316

Committed r225570: <https://trac.webkit.org/changeset/225570>
Comment 13 WebKit Commit Bot 2017-12-05 23:56:33 PST
All reviewed patches have been landed.  Closing bug.
Comment 14 Joseph Pecoraro 2017-12-06 10:29:33 PST
(In reply to Timothy Hatcher from comment #9)
> Maybe the right solution would be to allow editing existing values, pressing
> backspace clears and stays focused in the value, but a second backspace
> jumps to the name and selects it. That way if you do just want to clear the
> value and type a new one it works as expected, but you can get to the value
> too.

That was what I was thinking as well.
Comment 15 Nikita Vasilyev 2017-12-06 16:57:18 PST
(In reply to Devin Rousso from comment #11)
> Comment on attachment 328316 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=328316&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js:266
> >> +            if (!this.value) {
> > 
> > I think this does implement what I said in my last comment on how I think it should work. An initial backspace would happen when this has a value and it would just fall through and clear it as an editing operation.
> 
> Correct!  It will only jump back to the name (by calling
> `spreadsheetTextFieldDidBackspace`) if the editor has no content.  It would
> require two backspaces, the first of which to delete the existing value, to
> move between editors.

I like this!

Nit: please retitle the bug before uploading the patch next time.