Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Don't trigger element insertion when focused inside a text field / inside custom CSS #7

Open
1 task done
jrmyfranck opened this issue Oct 10, 2023 · 7 comments
Assignees
Labels
🪲 bug confirmed The bug could be reproduced and is confirmed 🔧 in progress Development is in progress

Comments

@jrmyfranck
Copy link

jrmyfranck commented Oct 10, 2023

Contact Details

hello@jrmyfranck.com

What happened?

Currently, Structeezy shortcuts fire the corresponding insertions regardless of context.

While handy to quickly add elements to the page, it can trigger unwanted insertions.
It's especially problematic with the default shortcuts, when trying to add custom CSS to an element on a mac:

  1. I'll focus in the custom CSS field
  2. I'll type "%root%"
  3. I'll then intend to open my code block by typing "{", but this requires me to press the "alt" and "(" keys (for context, the open parenthesis key (() is also the 5 key
  4. Structeezy adds an <h5> element to the page

Potentially the same issues could occur when trying to type a "œ", "æ", etc., ie. in a text field

Version

v0.4.0

Version

v1.9.1.1

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jrmyfranck jrmyfranck added the 🪳 bug Something isn't working label Oct 10, 2023
@cbontems
Copy link
Contributor

cbontems commented Nov 8, 2023

Hello @jrmyfranck,

I confirm this behaviour with the defaults shortcuts. I'll look for a way to avoid triggering depending on the context.

In the mean time, maybe shortcuts like alt + h + 5 for headings instead of only alt + 5 could help even if they are more tricky to type ?

@cbontems cbontems added 🪲 bug confirmed The bug could be reproduced and is confirmed 🔧 in progress Development is in progress and removed 🪳 bug Something isn't working labels Nov 8, 2023
@jrmyfranck
Copy link
Author

In the mean time, maybe shortcuts like alt + h + 5 for headings instead of only alt + 5 could help even if they are more tricky to type ?

That's what I ended up doing, and it does work as a workaround. However if Structeezy was context-aware that would obviously be better.

Not sure at all whether it is feasible, but I'm sharing this in case it's helpful at all:
Maybe by checking which element is currently focused, and preventing Structeezy functions if the focus is inside a Bricks field, a text field (on the page) or the custom CSS field?

@cbontems
Copy link
Contributor

cbontems commented Nov 8, 2023

I think I have this one solved also. Feedback from users will tell if it is OK.

It was a bit tricky because Bricks uses <input> elements for the structure tree, therefore checking only for the active element type not being an input or textarea was not enough.

@cbontems
Copy link
Contributor

Hello @jrmyfranck,

Did you have a chance to upgrade to the latest version and check if the problem is solved for you?

Thanks.

@jrmyfranck
Copy link
Author

Hey @cbontems, haven't had the chance to thoroughly test it yet (been busy with non-Bricks related projects). I‘ll try to get to it during the weekend, and will report back.

@jrmyfranck
Copy link
Author

@cbontems working now when editing text.

However, I noticed this behaviour when focused inside one of Bricks fields in the Styles panel (ie. when adding a class, or adding a value for a CSS property):

  • A shortcut to insert an element will not fire.
  • However, the shorcut to open/hide the panel still fires.

I don't know if that’s intentional (and I don’t necessarily think it's a bad thing), but I wanted to let you know.

@cbontems
Copy link
Contributor

@jrmyfranck yes, I noticed this case too. They are different context, therefore not caught as the insertion one. I think it would be better to prevent shortcuts in all contexts, so I will change the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug confirmed The bug could be reproduced and is confirmed 🔧 in progress Development is in progress
Projects
None yet
Development

No branches or pull requests

2 participants