figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Prevent extra brackets`{ }` and whitespaces being added on token name searches (mentions)

Open cuserox opened this issue 1 year ago • 3 comments

Describe the bug Tweaking the extra space when token search is used (https://github.com/tokens-studio/figma-plugin/pull/2789) the way that search results are populated has been slightly broken!

To Reproduce Steps to reproduce the behavior:

  1. Edit a token to reference an alias
  2. Select an alias
  3. Edit the alias manually by searching
  4. Click on any result, see the bracket {} added randomly on the input

Expected behavior No extra bracket nor spaces should be added when a token name is clicked on after searching.

Screenshots or Screencasts https://github.com/tokens-studio/figma-plugin/assets/114073780/335dd67b-6bf2-484f-b528-03733e1a3d50

cuserox avatar Jun 21 '24 15:06 cuserox

@cuserox I have a fix for this available in six7/fix-mentions. It turns out a recent change we did to mentions was causing this. Removing this again makes everything work, except that the extra space at the end of the input is added. It's the split="" that was the issue.

Perhaps we could adjust this so after applying it strips out the extra space?

For example if you have a token like {fontsize-small}rem and you replace fontsize-small with something else, it adds an extra space. But it no longer adds the } after, which is a great improvement but the space is a bit of an issue (which we attempted to solve with that split="" but the sideeffects are worse with that.

six7 avatar Jun 22 '24 10:06 six7

@cuserox I have a fix for this available in six7/fix-mentions. It turns out a recent change we did to mentions was causing this. Removing this again makes everything work, except that the extra space at the end of the input is added. It's the split="" that was the issue.

Perhaps we could adjust this so after applying it strips out the extra space?

For example if you have a token like {fontsize-small}rem and you replace fontsize-small with something else, it adds an extra space. But it no longer adds the } after, which is a great improvement but the space is a bit of an issue (which we attempted to solve with that split="" but the sideeffects are worse with that.

@six7 makes sense. All in all, this fix should be for no side effects to occur when a user searches tokens 🔨

cuserox avatar Jun 24 '24 08:06 cuserox

@six7 @macintoshhelper @robinhoodie0823

I have created a Draft MR here, merely because it needs more testing. I believe it works well with my fix, but I wouldn't want to merge it and cause more trouble for V2 (and I'm off this Friday & Monday) 😇

Therefore if it's a pressing fix that needs to go out, please feel free to tweak, test & merge if needed!

cuserox avatar Jun 27 '24 17:06 cuserox

We'll tackle this with https://github.com/tokens-studio/figma-plugin/issues/2998

six7 avatar Aug 05 '24 08:08 six7