Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-5626: set autofocus end on message edit #4784

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/text-editor/src/components/ReferenceInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
checkAdaptiveMatching
} from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import { FocusPosition } from '@tiptap/core'

import { Completion } from '../Completion'
import textEditorPlugin from '../plugin'
import { RefAction, TextEditorHandler, TextFormatCategory } from '../types'
Expand All @@ -47,6 +49,7 @@
export let loading: boolean = false
export let focusable: boolean = false
export let boundary: HTMLElement | undefined = undefined
export let autofocus: FocusPosition = false

const dispatch = createEventDispatcher()
const buttonSize = 'medium'
Expand Down Expand Up @@ -126,6 +129,7 @@
<TextEditor
bind:content
bind:this={textEditor}
{autofocus}
{boundary}
on:content={(ev) => {
if (!isEmpty || haveAttachment) {
Expand Down
2 changes: 2 additions & 0 deletions packages/text-editor/src/components/TextEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
export let supportSubmit = true
export let editorAttributes: Record<string, string> = {}
export let boundary: HTMLElement | undefined = undefined
export let autofocus: FocusPosition = false

let element: HTMLElement
let editor: Editor
Expand Down Expand Up @@ -123,6 +124,7 @@
element,
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, editorAttributes) },
content,
autofocus,
extensions: [
EditorKit,
...(supportSubmit ? [Handle] : []), // order important
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
import { Attachment } from '@hcengineering/attachment'
import { Account, Class, Doc, generateId, IdMap, Ref, Space, toIdMap } from '@hcengineering/core'
import { IntlString, setPlatformStatus, unknownError, Asset } from '@hcengineering/platform'
import {
createQuery,
DraftController,
draftsStore,
getClient,
getFileUrl,
getImageSize
} from '@hcengineering/presentation'
import { createQuery, DraftController, draftsStore, getClient } from '@hcengineering/presentation'
import textEditor, { AttachIcon, type RefAction, ReferenceInput } from '@hcengineering/text-editor'
import { Loading, type AnySvelteComponent } from '@hcengineering/ui'
import { deleteFile, getAttachmentMetadata, uploadFile } from '../utils'
Expand All @@ -43,6 +36,7 @@
export let attachments: IdMap<Attachment> = new Map()
export let loading = false
export let focusIndex: number = -1
export let autofocus = false
export function submit (): void {
refInput.submit()
}
Expand Down Expand Up @@ -296,6 +290,7 @@
{labelSend}
{showSend}
{showActions}
autofocus={autofocus ? 'end' : false}
loading={loading || progress}
{boundary}
extraActions={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
export let boundary: HTMLElement | undefined = undefined
export let loading = false
export let collection: string = 'comments'
export let autofocus = false

type MessageDraft = Pick<ChatMessage, '_id' | 'message' | 'attachments'>

Expand Down Expand Up @@ -186,6 +187,7 @@
bind:objectId={_id}
{shouldSaveDraft}
{boundary}
{autofocus}
on:message={onMessage}
on:update={onUpdate}
on:focus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
{isSelected}
{shouldScroll}
{embedded}
{withActions}
withActions={withActions && !isEditing}
actions={additionalActions}
{showEmbedded}
{hideFooter}
Expand Down Expand Up @@ -213,6 +213,8 @@
bind:this={refInput}
chatMessage={value}
shouldSaveDraft={false}
focusIndex={1000}
autofocus
{object}
on:submit={() => {
isEditing = false
Expand Down
Loading