Closed Bug 1254070 Opened 8 years ago Closed 8 years ago

markup-view: style attribute autocomplete works only when caret is at the end of the input

Categories

(DevTools :: Inspector, defect, P2)

47 Branch
defect

Tracking

(firefox44 wontfix, firefox45 wontfix, firefox46 wontfix, firefox47 wontfix, firefox48 wontfix, firefox49 wontfix, firefox50 fixed)

RESOLVED FIXED
Firefox 50
Tracking Status
firefox44 --- wontfix
firefox45 --- wontfix
firefox46 --- wontfix
firefox47 --- wontfix
firefox48 --- wontfix
firefox49 --- wontfix
firefox50 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

Details

(Keywords: regression, Whiteboard: [btpp-fix-later])

Attachments

(1 file, 1 obsolete file)

STRs:
- open the markup view
- add an attribute on any node
- type `style="color: red;"`

Expected: 
- should have autocompletion both for the property name and the property value

Actual:
- autocompletion is not working
This regression was caused by Bug 913955 .

The fix is quite simple, the test at https://dxr.mozilla.org/mozilla-central/source/devtools/client/shared/inplace-editor.js#1155 

should change from:

> input.selectionStart < input.value.length

to

> input.selectionStart < input.value.length - 1

pbro: This feature has been missing for 2 years and no one complained. Can you confirm we should resurrect it?
Flags: needinfo?(pbrosset)
Has STR: --- → yes
Keywords: regression
Blocks: 916582
As discussed on IRC, the autocompletion only works if you are editing the last character of the attribute. If you are writing first `style=""` and then typing between the quotes, the autocompletion is not triggered. 

and input.selectionStart < input.value.length is actually a valid test, true only when the selection is after the last character of the input.
Flags: needinfo?(pbrosset)
No longer blocks: 916582
Summary: markup-view: style attribute autocomplete is not working → markup-view: style attribute autocomplete works only when caret is at the end of the input
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Filter on CLIMBING SHOES
Priority: -- → P2
Whiteboard: [btpp-fix-later]
Attached patch bug1254070.wip.patch (obsolete) — Splinter Review
Gabriel: The patch summary is a bit confusing, so I rephrase it here. The goal is to make the autocomplete of the style attribute a bit more flexible. Right now it works only when we are at the end of the input or if the next character is a space.

I think you added the condition checking for end of input or space in Bug 913955, so I'd like your feedback here.

This patch proposes to activate the autocompletion if the next character is not a "word" caracter or a dash. We could further restrict this behaviour to the MIXED_CONTENT type (ie. style attribute only) but I think it can be useful in the rule view as well.
Attachment #8728400 - Flags: feedback?(gl)
Blocks: 913955
Flags: needinfo?(scrapmachines)
Hello Julian, this bug was reviewed in the Platform triage meeting and it seems the wip patch got stuck somewhere along the way. Do you want to find another reviewer?
Flags: needinfo?(jdescottes)
Comment on attachment 8728400 [details] [diff] [review]
bug1254070.wip.patch

Let's try with a mozreview request! Would really prefer :gl to have a look here.

Try push for the rebased patch: https://treeherder.mozilla.org/#/jobs?repo=try&revision=dec28360df75
Attachment #8728400 - Attachment is obsolete: true
Flags: needinfo?(scrapmachines)
Flags: needinfo?(jdescottes)
Attachment #8728400 - Flags: feedback?(gl)
Comment on attachment 8756866 [details]
Bug 1254070 - inspector: trigger autocomplete if nextchar is not a word character;

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/55454/diff/1-2/
Test needed updating after rebase. New try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2cd71e06b265
Comment on attachment 8756866 [details]
Bug 1254070 - inspector: trigger autocomplete if nextchar is not a word character;

https://reviewboard.mozilla.org/r/55454/#review52418

::: devtools/client/inspector/markup/test/browser_markup_css_completion_style_attribute_03.js:51
(Diff revision 2)
> +  ["VK_RETURN", "style=\"color:beige;padding:0;\"",
> +   -1, -1, false]
> +];
> +
> +add_task(function* () {
> +  info("Opening the inspector on the test URL");

Remove this info() since it is repeating openInspectorForURL()
Attachment #8756866 - Flags: review?(gl) → review+
https://reviewboard.mozilla.org/r/55454/#review54680

::: devtools/client/shared/inplace-editor.js:1305
(Diff revision 2)
>        // If nothing is selected and there is a non-space character after the
>        // cursor, do not autocomplete.
>        if (input.selectionStart == input.selectionEnd &&
> -          input.selectionStart < input.value.length &&
> -          input.value.slice(input.selectionStart)[0] != " ") {
> +          input.selectionStart < input.value.length) {
> +        let nextChar = input.value.slice(input.selectionStart)[0];
> +        // Check the next character if editing inside a word.

Can we also add a bit more detail on this comment as well?
Comment on attachment 8756866 [details]
Bug 1254070 - inspector: trigger autocomplete if nextchar is not a word character;

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/55454/diff/2-3/
Attachment #8756866 - Attachment description: MozReview Request: Bug 1254070 - inspector: trigger autocomplete if nextchar is not a word character;r=gl → Bug 1254070 - inspector: trigger autocomplete if nextchar is not a word character;
https://reviewboard.mozilla.org/r/55454/#review52418

Thanks for the review! Try (https://treeherder.mozilla.org/#/jobs?repo=try&revision=2cd71e06b265) is green, landing.

> Remove this info() since it is repeating openInspectorForURL()

Done (also removed from the two similar test files browser_markup_css_completion_style_attribute_01 & 02)
https://reviewboard.mozilla.org/r/55454/#review54680

> Can we also add a bit more detail on this comment as well?

Done
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/fx-team/rev/a48604c3b495
inspector: trigger autocomplete if nextchar is not a word character;r=gl
https://hg.mozilla.org/mozilla-central/rev/a48604c3b495
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 50
Julien, Gabriel, are you going to ask for an uplift to fix 48 and 49?
Thanks
Flags: needinfo?(jdescottes)
Flags: needinfo?(gl)
No uplift will be requested, marking as wontfix for 48 and 49.
Flags: needinfo?(jdescottes)
Flags: needinfo?(gl)
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: