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

[v4] Textarea toolbar button click makes scroll position jump #5906

Closed
nilshoerrmann opened this issue Nov 2, 2023 · 10 comments
Closed

[v4] Textarea toolbar button click makes scroll position jump #5906

nilshoerrmann opened this issue Nov 2, 2023 · 10 comments
Assignees
Milestone

Comments

@nilshoerrmann
Copy link
Contributor

Description

When editing content in a textarea field, the toolbar creates unexpected Markdown for block elements. Think of this existing content, the pipe being the cursor:

# An example |headline

If I select headline 3 in the toolbar, the following will be created:

# An example ### |headline

Same example as before, if I click headline 1 again to unselect it and make the current line a paragraph again, the following will be created:

# An example # |headline

Expected behavior
The block level elements should alter the Markdown blocks and not thus change the marks at the very beginning of the line.

To reproduce

title: Markdown Test
fields:
  text:
    label: Text
    type: textarea

Your setup

Kirby Version
Kirby 4 Beta 3 on Firefox 119 (macOS Sonoma)

@nilshoerrmann
Copy link
Contributor Author

Additional issue: when selecting a mark in the toolbar, the panel jumps to the top when scrolled. Test with long content that will expand the textarea below "the fold".

@distantnative
Copy link
Member

Is the top issue any different than v3?

@nilshoerrmann
Copy link
Contributor Author

Oh, that's a good question I will have to check.
Haven't used the textarea field with toolbar in v3 for a long time.

@nilshoerrmann
Copy link
Contributor Author

I just checked on 3.9 and the behaviour is the same. But I'm sure this was handled differently in earlier versions (like very early v3).

@distantnative
Copy link
Member

I really doubt that. Looking at earlier versions e.g. 3.3 it always seems to have been a simple prepend to the cursor selection.

Maybe you're thinking of https://github.com/fabianmichael/kirby-markdown-field ?

@nilshoerrmann
Copy link
Contributor Author

The Markdown field is what we usually use because of the highlighting. So yes, that might well be possible.
But do we agree that the textarea behaviour is a bit … surprising? 😀

@distantnative
Copy link
Member

Yes and no. The textarea buttons have been quite basic, so I do see that one could request the enhancement that they get smarter. But that'd also mean adding quite some more logic, which could be worth it. But it's not a simple fix or changing it back to how it once was.

In fact, with v4 the buttons get a tiny bit smarter: Where in the past wrapping ** were always just added/inserted (again and again and again with each click), they now do get removed when the current selection is already wrapped.

@distantnative
Copy link
Member

Added as idea: https://kirby.nolt.io/588

Will focus this issue on the jumping bug you describe in post # 2

@distantnative distantnative changed the title [v4] Textarea toolbar treats block like inline content when inserting marks [v4] Textarea toolbar button click makes scroll position jump Nov 2, 2023
@nilshoerrmann
Copy link
Contributor Author

nilshoerrmann commented Nov 2, 2023

The main issue I see it that it generates invalid Markdown which is actually the reason why we provide the buttons to editors in the first place: they are not fluent enough in Markdown to write it blindly.

But, please, feel free to consider this a feature request 👍

@nilshoerrmann
Copy link
Contributor Author

nilshoerrmann commented Nov 2, 2023

Ah, just saw the Nolt entry. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants