Improvements to the code block

Hello!

I’m not sure if this was an intended behaviour or a bug. To me, though, I feel like the current behaviour as it is shouldn’t be the case; therefore, I’ll file this as a bug for now. If it isn’t apologies!

I’ve started experimenting with code blocks earlier, and it’s mostly neat! I like the syntax highlighting applied that’s relative to the programming language selected. Even so, however, I believe that there are some small details that, if possibly improved upon, can make code blocks all the more better.

Code block overlay not dismissing when clicked elsewhere

I noticed this behaviour when playing around with the code blocks; take a look at the video:
overlay.mp4

I noticed that the overlay that appears when double clicking a word in the code block doesn’t dismiss itself when I click away; not just on another place within the same code block, but clicked in other blocks as well. The only time it dismisses itself is when the escape button is pressed.

Perhaps this is a bug? I imagine this overlay to dismiss itself the moment I click elsewhere or start typing. What are your thoughts?

Type to search capability for programming language dropdown list

Currently, there’s quite an expansive list of programming languages in the dropdown list of the code blocks. That’s a great thing to have!

Even so, however, I think there may be a little bit of friction whenever creating code blocks for different programming languages. The dropdown list is quite expansive, but the user needs to scroll through the list to find and select a programming language.

If something like how dropdown menus are currently handled — the moment a user presses a button (say, “p”), the dropdown list jumps to the first item that starts with “p” — is implemented, I think it can save some effort! Once again, what are your thoughts?

That’s all I have for now. After experimenting with the code block, it’s safe to say that it works as expected for the most part. Cheers and thanks for reading it this far!

2 Likes

#1 seems to be a duplicate of [this](https://community.anytype.io/d/74-menu-appearing-when-text-is-selected-should-go-away-when-you-click-anywhere-els). Either way, I think the ‘overlay’ should not even pop up in code blocks, it is useless. It has only three functions: turn into, move to, delete; all of which you can do more easily using the three dot menu to the left of the code block. No one would really think of using the pop up overlay because normally they are used to control a block (a line of text) but in this case it controls the whole code block.

I definitely agree with you on #2.

By the way, you said you ‘filed this as a bug report’ but it appears to be a feature request.

2 Likes

Thanks for linking me to this! It definitely seems like the case here. I can agree with you that the overlay has not much of a purpose in code blocks. After all, all the functionality given by the overlay can be done at the side.

Oh whoops, sorry about that! I initially wrote this to be about the first issue; when I added the second, I looked over this bit.

This is currently not a function anymore.

There was a search field implemented.

If you are okay with those changes, feel free to select a message as the solution. Otherwise let us know, what is missing.