fix: open menu to the top when at the bottom of the screen

This commit is contained in:
Antonella Sgarlatta
2021-05-07 18:35:02 -03:00
parent 437aa40d7a
commit 24eb348b08
3 changed files with 18 additions and 8 deletions

View File

@@ -62,6 +62,7 @@ type NoteFlag = {
*/
const MIN_NOTE_CELL_HEIGHT = 51.0;
const DEFAULT_LIST_NUM_NOTES = 20;
const MAX_CONTEXT_MENU_HEIGHT = 245;
const ELEMENT_ID_SEARCH_BAR = 'search-bar';
const ELEMENT_ID_SCROLL_CONTAINER = 'notes-scrollable';
@@ -304,10 +305,18 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
await this.selectNote(note);
}
if (this.state.selectedNotes[note.uuid]) {
this.application.getAppState().notes.setContextMenuPosition({
top: e.clientY,
left: e.clientX,
});
const clientHeight = document.documentElement.clientHeight;
if (e.clientY > clientHeight - MAX_CONTEXT_MENU_HEIGHT) {
this.application.getAppState().notes.setContextMenuPosition({
bottom: clientHeight - e.clientY,
left: e.clientX,
});
} else {
this.application.getAppState().notes.setContextMenuPosition({
top: e.clientY,
left: e.clientX,
});
}
this.application.getAppState().notes.setContextMenuOpen(true);
}
}