TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

jsxAttributeCompletionStyle doesn't work as expected

Open svipas opened this issue 3 years ago • 2 comments

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.71.2
  • OS Version: macOS 12.6
  • TS Version: 4.8.2

Steps to Reproduce:

Make sure jsxAttributeCompletionStyle is enabled for TS/JS.

As you can see from screenshot above that it doesn't insert flex, but flex={} even though ={} already exists. And it does the same thing for everything, in this case braces shouldn't be added because they already exist.

You can try yourself with code below (JavaScript React):

function Button() {
  return (
    <div className="">
    </div>
  )
}

Delete className and try to write it again you will see it tries to insert className='' instead of className, even though ='' already exists.

➡️ Tested and same happens in latest Insiders clean build without any extensions with default config. ⬅️

svipas avatar Oct 02 '22 19:10 svipas

Confirmed that the insert text returned in this case is:

 "insertText": "className=\"$1\"",

mjbvz avatar Oct 05 '22 22:10 mjbvz

@RyanCavanaugh I see @a-tarasyuk created a PR with fix: https://github.com/microsoft/TypeScript/pull/51093

svipas avatar Nov 03 '22 08:11 svipas