fix: notes view not selected on launch issue
This commit is contained in:
@@ -89,7 +89,6 @@ export class TagsState extends AbstractState {
|
|||||||
this.addingSubtagTo = undefined
|
this.addingSubtagTo = undefined
|
||||||
|
|
||||||
this.smartViews = this.application.items.getSmartViews()
|
this.smartViews = this.application.items.getSmartViews()
|
||||||
this.selected_ = this.smartViews[0]
|
|
||||||
|
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
tags: observable.ref,
|
tags: observable.ref,
|
||||||
@@ -145,17 +144,18 @@ export class TagsState extends AbstractState {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updatedReference =
|
||||||
|
FindItem(changed, currrentSelectedTag.uuid) || FindItem(this.smartViews, currrentSelectedTag.uuid)
|
||||||
|
if (updatedReference) {
|
||||||
|
this.setSelectedTagInstance(updatedReference as AnyTag)
|
||||||
|
}
|
||||||
|
|
||||||
if (isSystemView(currrentSelectedTag as SmartView)) {
|
if (isSystemView(currrentSelectedTag as SmartView)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindItem(removed, currrentSelectedTag.uuid)) {
|
if (FindItem(removed, currrentSelectedTag.uuid)) {
|
||||||
this.setSelectedTagInstance(this.smartViews[0])
|
this.setSelectedTagInstance(this.smartViews[0])
|
||||||
} else {
|
|
||||||
const updated = FindItem(changed, currrentSelectedTag.uuid)
|
|
||||||
if (updated) {
|
|
||||||
this.setSelectedTagInstance(updated as AnyTag)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
@@ -244,22 +244,21 @@ export class TagsState extends AbstractState {
|
|||||||
const footerElementRect = document.getElementById('footer-bar')?.getBoundingClientRect()
|
const footerElementRect = document.getElementById('footer-bar')?.getBoundingClientRect()
|
||||||
const footerHeightInPx = footerElementRect?.height
|
const footerHeightInPx = footerElementRect?.height
|
||||||
|
|
||||||
// Open up-bottom is default behavior
|
|
||||||
let openUpBottom = true
|
let openUpBottom = true
|
||||||
|
|
||||||
if (footerHeightInPx) {
|
if (footerHeightInPx) {
|
||||||
const bottomSpace = clientHeight - footerHeightInPx - this.contextMenuClickLocation.y
|
const bottomSpace = clientHeight - footerHeightInPx - this.contextMenuClickLocation.y
|
||||||
const upSpace = this.contextMenuClickLocation.y
|
const upSpace = this.contextMenuClickLocation.y
|
||||||
|
|
||||||
// If not enough space to open up-bottom
|
const notEnoughSpaceToOpenUpBottom = maxContextMenuHeight > bottomSpace
|
||||||
if (maxContextMenuHeight > bottomSpace) {
|
if (notEnoughSpaceToOpenUpBottom) {
|
||||||
// If there's enough space, open bottom-up
|
const enoughSpaceToOpenBottomUp = upSpace > maxContextMenuHeight
|
||||||
if (upSpace > maxContextMenuHeight) {
|
if (enoughSpaceToOpenBottomUp) {
|
||||||
openUpBottom = false
|
openUpBottom = false
|
||||||
this.setContextMenuMaxHeight('auto')
|
this.setContextMenuMaxHeight('auto')
|
||||||
// Else, reduce max height (menu will be scrollable) and open in whichever direction there's more space
|
|
||||||
} else {
|
} else {
|
||||||
if (upSpace > bottomSpace) {
|
const hasMoreUpSpace = upSpace > bottomSpace
|
||||||
|
if (hasMoreUpSpace) {
|
||||||
this.setContextMenuMaxHeight(upSpace - MENU_MARGIN_FROM_APP_BORDER)
|
this.setContextMenuMaxHeight(upSpace - MENU_MARGIN_FROM_APP_BORDER)
|
||||||
openUpBottom = false
|
openUpBottom = false
|
||||||
} else {
|
} else {
|
||||||
@@ -414,14 +413,14 @@ export class TagsState extends AbstractState {
|
|||||||
this.selected = editingTag
|
this.selected = editingTag
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createNewTemplate() {
|
public createNewTemplate() {
|
||||||
const isAlreadyEditingATemplate = this.editing_ && this.application.items.isTemplateItem(this.editing_)
|
const isAlreadyEditingATemplate = this.editing_ && this.application.items.isTemplateItem(this.editing_)
|
||||||
|
|
||||||
if (isAlreadyEditingATemplate) {
|
if (isAlreadyEditingATemplate) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTag = (await this.application.mutator.createTemplateItem(ContentType.Tag)) as SNTag
|
const newTag = this.application.mutator.createTemplateItem(ContentType.Tag) as SNTag
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.editing_ = newTag
|
this.editing_ = newTag
|
||||||
|
|||||||
Reference in New Issue
Block a user