Skip to content

Commit 20d7df5

Browse files
committed
Handle theme dropdown menu resizing
Signed-off-by: Yukai Huang <[email protected]>
1 parent 62980b3 commit 20d7df5

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

public/js/lib/editor/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/* global CodeMirror, $, editor, Cookies */
2+
import { options, Alignment, FormatType } from '@susisu/mte-kernel'
3+
import debounce from 'lodash/debounce'
4+
25
import * as utils from './utils'
36
import config from './config'
47
import statusBarTemplate from './statusbar.html'
58
import toolBarTemplate from './toolbar.html'
69
import './markdown-lint'
710
import { initTableEditor } from './table-editor'
8-
import { options, Alignment, FormatType } from '@susisu/mte-kernel'
911
import { availableThemes } from './constants'
12+
import { } from './ui-elements'
1013

1114
/* config section */
1215
const isMac = CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault
@@ -326,6 +329,8 @@ export default class Editor {
326329
this.setSpellcheck()
327330
this.setLinter()
328331
this.setPreferences()
332+
333+
this.handleStatusBarResize()
329334
}
330335

331336
updateStatusBar () {
@@ -350,6 +355,21 @@ export default class Editor {
350355
}
351356
}
352357

358+
handleStatusBarResize () {
359+
const onResize = debounce(() => {
360+
if (!this.statusBar) {
361+
return
362+
}
363+
364+
const maxHeight = window.innerHeight - this.statusBar.height() - 50 /* navbar height */ - 10 /* spacing */
365+
this.statusBar.find('.status-theme ul.dropdown-menu').css('max-height', `${maxHeight}px`)
366+
}, 300)
367+
368+
$(window).resize(onResize)
369+
370+
onResize()
371+
}
372+
353373
setIndent () {
354374
var cookieIndentType = Cookies.get('indent_type')
355375
var cookieTabSize = parseInt(Cookies.get('tab_size'))

public/js/lib/editor/statusbar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
<div class="indent-width-label" title="Click to change indentation size">4</div>
3232
<input class="indent-width-input hidden" type="number" min="1" max="10" maxlength="2" size="2">
3333
</div>
34-
<div class="status-theme dropup pull-right">
34+
<div class="status-theme dropup">
3535
<a id="themeLabel" class="ui-theme-label text-uppercase" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="Select theme">
3636
<i class="fa fa-paint-brush fa-fw"></i>
3737
</a>
38-
<ul class="dropdown-menu" aria-labelledby="themeLabel">
38+
<ul class="dropdown-menu" aria-labelledby="themeLabel" style="overflow: auto;">
3939
</ul>
4040
</div>
4141
<div class="status-spellcheck">

0 commit comments

Comments
 (0)