diff --git a/packages/web/src/javascripts/Components/ContentListView/Daily/DailyItemCell.tsx b/packages/web/src/javascripts/Components/ContentListView/Daily/DailyItemCell.tsx
index 5cc1308e0..7c868262a 100644
--- a/packages/web/src/javascripts/Components/ContentListView/Daily/DailyItemCell.tsx
+++ b/packages/web/src/javascripts/Components/ContentListView/Daily/DailyItemCell.tsx
@@ -9,7 +9,6 @@ import { ListableContentItem } from '../Types/ListableContentItem'
import { DailyItemsDay } from './DailyItemsDaySection'
import { ListItemTitle } from '../ListItemTitle'
import { EmptyPlaceholderBars } from './EmptyPlaceholderBars'
-import { isMobileScreen } from '@/Utils'
type DaySquareProps = {
day: number
@@ -73,7 +72,7 @@ export const DailyItemCell = forwardRef(
{!item && (
{formatDateAndTimeForNote(section.date, false)}
-
+
)}
diff --git a/packages/web/src/javascripts/Components/NoteView/NoteView.tsx b/packages/web/src/javascripts/Components/NoteView/NoteView.tsx
index 00f5b6803..8d771f123 100644
--- a/packages/web/src/javascripts/Components/NoteView/NoteView.tsx
+++ b/packages/web/src/javascripts/Components/NoteView/NoteView.tsx
@@ -95,7 +95,7 @@ class NoteView extends AbstractComponent {
private protectionTimeoutId: ReturnType | null = null
private noteViewElementRef: RefObject
private editorContentRef: RefObject
- private plainEditorRef?: RefObject
+ private plainEditorRef?: PlainEditorInterface
constructor(props: NoteViewProps) {
super(props, props.application)
@@ -231,6 +231,18 @@ class NoteView extends AbstractComponent {
}
}
+ setPlainEditorRef = (ref: PlainEditorInterface | undefined) => {
+ this.plainEditorRef = ref || undefined
+
+ if (!this.plainEditorRef) {
+ return
+ }
+
+ if (this.controller.isTemplateNote && this.controller.templateNoteOptions?.autofocusBehavior === 'editor') {
+ this.plainEditorRef.focus()
+ }
+ }
+
override componentDidUpdate(_prevProps: NoteViewProps, prevState: State): void {
if (
this.state.showProtectedWarning != undefined &&
@@ -569,7 +581,7 @@ class NoteView extends AbstractComponent {
}
currentTarget.blur()
- this.plainEditorRef?.current?.focus()
+ this.plainEditorRef?.focus()
}
onTitleChange: ChangeEventHandler = ({ currentTarget }) => {
@@ -944,7 +956,7 @@ class NoteView extends AbstractComponent {
this.setPlainEditorRef(ref || undefined)}
controller={this.controller}
locked={this.state.noteLocked}
onFocus={this.onPlainFocus}
diff --git a/packages/web/src/javascripts/Components/NoteView/PlainEditor/PlainEditor.tsx b/packages/web/src/javascripts/Components/NoteView/PlainEditor/PlainEditor.tsx
index ee4053099..76781f70f 100644
--- a/packages/web/src/javascripts/Components/NoteView/PlainEditor/PlainEditor.tsx
+++ b/packages/web/src/javascripts/Components/NoteView/PlainEditor/PlainEditor.tsx
@@ -33,7 +33,7 @@ export type PlainEditorInterface = {
}
export const PlainEditor = forwardRef(
- ({ application, spellcheck, controller, locked, onFocus, onBlur }: Props, ref) => {
+ ({ application, spellcheck, controller, locked, onFocus, onBlur }, ref) => {
const [editorText, setEditorText] = useState()
const [textareaUnloading, setTextareaUnloading] = useState(false)
const [lineHeight, setLineHeight] = useState()
@@ -239,7 +239,7 @@ export const PlainEditor = forwardRef(
onFocus={onContentFocus}
onBlur={onContentBlur}
readOnly={locked}
- ref={(ref) => ref && onRef(ref)}
+ ref={onRef}
spellCheck={spellcheck}
value={editorText}
className={classNames(
diff --git a/packages/web/src/javascripts/Controllers/ItemList/ItemListController.ts b/packages/web/src/javascripts/Controllers/ItemList/ItemListController.ts
index 79d082544..10295ab91 100644
--- a/packages/web/src/javascripts/Controllers/ItemList/ItemListController.ts
+++ b/packages/web/src/javascripts/Controllers/ItemList/ItemListController.ts
@@ -610,7 +610,7 @@ export class ItemListController extends AbstractViewController implements Intern
async createNewNoteController(
title?: string,
createdAt?: Date,
- autofocusBehavior?: TemplateNoteViewAutofocusBehavior,
+ autofocusBehavior: TemplateNoteViewAutofocusBehavior = 'editor',
) {
const selectedTag = this.navigationController.selected
diff --git a/packages/web/src/javascripts/Utils/Items/Search/getSearchResults.ts b/packages/web/src/javascripts/Utils/Items/Search/getSearchResults.ts
index ff0ae42ff..4080754d6 100644
--- a/packages/web/src/javascripts/Utils/Items/Search/getSearchResults.ts
+++ b/packages/web/src/javascripts/Utils/Items/Search/getSearchResults.ts
@@ -6,8 +6,12 @@ import { isSearchResultExistingTag } from './isSearchResultExistingTag'
import { ItemLink } from './ItemLink'
import { LinkableItem } from './LinkableItem'
-const ResultLimitPerContentType = 5
-const MaxLinkedResults = 20
+const MaxLinkedResults = 50
+
+function resultLimitForSearchQuery(query: string): number {
+ const limitPerContentType = 10
+ return Math.max(limitPerContentType, query.length * 3)
+}
export function getLinkingSearchResults(
searchQuery: string,
@@ -77,27 +81,22 @@ export function getLinkingSearchResults(
const enforceResultLimit = options.contentType == null
+ const limitPerContentType = resultLimitForSearchQuery(searchQuery)
+
if (
item.content_type === ContentType.Tag &&
- (!enforceResultLimit ||
- (unlinkedTags.length < ResultLimitPerContentType && item.content_type === ContentType.Tag))
+ (!enforceResultLimit || (unlinkedTags.length < limitPerContentType && item.content_type === ContentType.Tag))
) {
unlinkedTags.push(item)
continue
}
- if (
- item.content_type === ContentType.Note &&
- (!enforceResultLimit || unlinkedNotes.length < ResultLimitPerContentType)
- ) {
+ if (item.content_type === ContentType.Note && (!enforceResultLimit || unlinkedNotes.length < limitPerContentType)) {
unlinkedNotes.push(item)
continue
}
- if (
- item.content_type === ContentType.File &&
- (!enforceResultLimit || unlinkedFiles.length < ResultLimitPerContentType)
- ) {
+ if (item.content_type === ContentType.File && (!enforceResultLimit || unlinkedFiles.length < limitPerContentType)) {
unlinkedFiles.push(item)
continue
}