Skip to content

Commit 282125e

Browse files
0koGusted
authored andcommitted
fix(ui): ensure consistent switch position in markdown editor (go-gitea#7492)
Followup to https://codeberg.org/forgejo/forgejo/pulls/7481. Fix a bug reported by @Gusted where the switch would jump ~1px up when switched to preview mode. It was because the switch is always center-aligning to the largest element in the toolbar. With toolbar buttons disappearing, the largest element was the switch itself. By placing it in a box with same height as the buttons we can ensure it can always stay in the same position. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7492 Reviewed-by: Gusted <[email protected]> Co-authored-by: 0ko <[email protected]> Co-committed-by: 0ko <[email protected]>
1 parent eca57cc commit 282125e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

templates/shared/combomarkdowneditor.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ Template Attributes:
1616

1717
<markdown-toolbar>
1818
{{if .MarkdownPreviewUrl}}
19-
<div class="switch">
20-
<a href="#" class="active item" data-tab-for="markdown-writer">{{ctx.Locale.Tr "write"}}</a>
21-
<a href="#" class="item" data-tab-for="markdown-previewer" data-preview-url="{{.MarkdownPreviewUrl}}" data-preview-context="{{.MarkdownPreviewContext}}">{{ctx.Locale.Tr "preview"}}</a>
19+
<div class="markdown-toolbar-switch">
20+
<div class="switch">
21+
<a href="#" class="active item" data-tab-for="markdown-writer">{{ctx.Locale.Tr "write"}}</a>
22+
<a href="#" class="item" data-tab-for="markdown-previewer" data-preview-url="{{.MarkdownPreviewUrl}}" data-preview-context="{{.MarkdownPreviewContext}}">{{ctx.Locale.Tr "preview"}}</a>
23+
</div>
2224
</div>
2325
{{end}}
2426
<div class="markdown-toolbar-group">

web_src/css/editor/combomarkdowneditor.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
flex-wrap: wrap;
1212
}
1313

14-
markdown-toolbar .switch .item {
14+
.markdown-toolbar-switch {
15+
display: flex;
16+
height: 30px;
17+
}
18+
.markdown-toolbar-switch .switch .item {
1519
padding: 0.25em 1em;
1620
}
1721

0 commit comments

Comments
 (0)