mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 08:48:01 +00:00
UBER-425: Tooltup/popup fixes (#3404)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
1a53af053c
commit
19ed49a32f
@ -344,12 +344,14 @@
|
|||||||
textEditor.clear()
|
textEditor.clear()
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:on:blur={() => {
|
on:blur={() => {
|
||||||
focused = false
|
focused = false
|
||||||
|
dispatch('blur', focused)
|
||||||
}}
|
}}
|
||||||
on:focus={() => {
|
on:focus={() => {
|
||||||
focused = true
|
focused = true
|
||||||
updateFocus()
|
updateFocus()
|
||||||
|
dispatch('focus', focused)
|
||||||
}}
|
}}
|
||||||
extensions={[completionPlugin]}
|
extensions={[completionPlugin]}
|
||||||
on:selection-update={updateFormattingState}
|
on:selection-update={updateFormattingState}
|
||||||
|
@ -161,24 +161,38 @@
|
|||||||
const inPopup: boolean =
|
const inPopup: boolean =
|
||||||
ev.x >= rectP.left && ev.x <= rectP.right && ev.y >= rectP.top - dT && ev.y <= rectP.bottom + dB
|
ev.x >= rectP.left && ev.x <= rectP.right && ev.y >= rectP.top - dT && ev.y <= rectP.bottom + dB
|
||||||
|
|
||||||
|
if ($tooltip.kind !== 'popup') {
|
||||||
if ((tooltipSW && !inTrigger) || !(inTrigger || inPopup)) hideTooltip()
|
if ((tooltipSW && !inTrigger) || !(inTrigger || inPopup)) hideTooltip()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: kind === 'submenu' ? fitSubmenu() : fitTooltip(tooltipHTML)
|
$: kind === 'submenu' ? fitSubmenu() : fitTooltip(tooltipHTML)
|
||||||
afterUpdate(() => (kind === 'submenu' ? fitSubmenu() : fitTooltip(tooltipHTML)))
|
afterUpdate(() => (kind === 'submenu' ? fitSubmenu() : fitTooltip(tooltipHTML)))
|
||||||
onDestroy(() => hideTooltip())
|
onDestroy(() => hideTooltip())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if $tooltip.kind === 'popup'}
|
||||||
|
<div
|
||||||
|
class="modal-overlay antiOverlay"
|
||||||
|
on:click|stopPropagation|preventDefault={() => closeTooltip()}
|
||||||
|
on:keydown|stopPropagation|preventDefault={() => {}}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
bind:innerWidth={docWidth}
|
bind:innerWidth={docWidth}
|
||||||
bind:innerHeight={docHeight}
|
bind:innerHeight={docHeight}
|
||||||
on:resize={hideTooltip}
|
on:resize={() => {
|
||||||
|
if ($tooltip.kind !== 'popup') {
|
||||||
|
hideTooltip()
|
||||||
|
}
|
||||||
|
}}
|
||||||
on:mousemove={(ev) => {
|
on:mousemove={(ev) => {
|
||||||
whileShow(ev)
|
whileShow(ev)
|
||||||
}}
|
}}
|
||||||
on:keydown={(evt) => {
|
on:keydown={(evt) => {
|
||||||
if (($tooltip.component || $tooltip.label) && evt.key === 'Escape') {
|
if (($tooltip.component || $tooltip.label) && evt.key === 'Escape' && $tooltip.kind !== 'popup') {
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
evt.stopImmediatePropagation()
|
evt.stopImmediatePropagation()
|
||||||
hideTooltip()
|
hideTooltip()
|
||||||
@ -211,6 +225,9 @@
|
|||||||
<svelte:component
|
<svelte:component
|
||||||
this={$tooltip.component}
|
this={$tooltip.component}
|
||||||
{...$tooltip.props}
|
{...$tooltip.props}
|
||||||
|
on:tooltip={(evt) => {
|
||||||
|
$tooltip = { ...$tooltip, ...evt.detail }
|
||||||
|
}}
|
||||||
on:update={onUpdate !== undefined ? onUpdate : async () => {}}
|
on:update={onUpdate !== undefined ? onUpdate : async () => {}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@ -430,4 +447,15 @@
|
|||||||
content: none;
|
content: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.modal-overlay {
|
||||||
|
z-index: 10000;
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
pointer-events: all;
|
||||||
|
touch-action: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -64,7 +64,7 @@ export function showTooltip (
|
|||||||
props?: any,
|
props?: any,
|
||||||
anchor?: HTMLElement,
|
anchor?: HTMLElement,
|
||||||
onUpdate?: (result: any) => void,
|
onUpdate?: (result: any) => void,
|
||||||
kind?: 'tooltip' | 'submenu'
|
kind?: 'tooltip' | 'submenu' | 'popup'
|
||||||
): void {
|
): void {
|
||||||
storedValue = {
|
storedValue = {
|
||||||
label,
|
label,
|
||||||
@ -74,9 +74,19 @@ export function showTooltip (
|
|||||||
props,
|
props,
|
||||||
anchor,
|
anchor,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
kind: kind ?? 'tooltip'
|
kind: undefined
|
||||||
}
|
}
|
||||||
tooltipstore.set(storedValue)
|
tooltipstore.update((old) => {
|
||||||
|
if (old.component === storedValue.component) {
|
||||||
|
if (old.kind !== undefined && storedValue.kind === undefined) {
|
||||||
|
storedValue.kind = old.kind
|
||||||
|
}
|
||||||
|
if (storedValue.kind === undefined) {
|
||||||
|
storedValue.kind = 'tooltip'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return storedValue
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeTooltip (): void {
|
export function closeTooltip (): void {
|
||||||
|
@ -237,7 +237,7 @@ export interface LabelAndProps {
|
|||||||
props?: any
|
props?: any
|
||||||
anchor?: HTMLElement
|
anchor?: HTMLElement
|
||||||
onUpdate?: (result: any) => void
|
onUpdate?: (result: any) => void
|
||||||
kind?: 'tooltip' | 'submenu'
|
kind?: 'tooltip' | 'submenu' | 'popup'
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListItem {
|
export interface ListItem {
|
||||||
|
@ -286,6 +286,8 @@
|
|||||||
{labelSend}
|
{labelSend}
|
||||||
{showSend}
|
{showSend}
|
||||||
{loading}
|
{loading}
|
||||||
|
on:focus
|
||||||
|
on:blur
|
||||||
on:message={onMessage}
|
on:message={onMessage}
|
||||||
haveAttachment={attachments.size > 0}
|
haveAttachment={attachments.size > 0}
|
||||||
withoutTopBorder={attachments.size > 0}
|
withoutTopBorder={attachments.size > 0}
|
||||||
|
@ -118,5 +118,7 @@
|
|||||||
{shouldSaveDraft}
|
{shouldSaveDraft}
|
||||||
on:message={onMessage}
|
on:message={onMessage}
|
||||||
on:update={onUpdate}
|
on:update={onUpdate}
|
||||||
|
on:focus
|
||||||
|
on:blur
|
||||||
bind:loading
|
bind:loading
|
||||||
/>
|
/>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import chunter, { Comment } from '@hcengineering/chunter'
|
import chunter, { Comment } from '@hcengineering/chunter'
|
||||||
import { createQuery } from '@hcengineering/presentation'
|
import { createQuery } from '@hcengineering/presentation'
|
||||||
import { Label, resizeObserver, Spinner } from '@hcengineering/ui'
|
import { Label, resizeObserver, Spinner, closeTooltip } from '@hcengineering/ui'
|
||||||
import { DocNavLink, ObjectPresenter } from '@hcengineering/view-resources'
|
import { DocNavLink, ObjectPresenter } from '@hcengineering/view-resources'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import CommentInput from './CommentInput.svelte'
|
import CommentInput from './CommentInput.svelte'
|
||||||
@ -42,6 +42,11 @@
|
|||||||
{ sort: { modifiedOn: SortingOrder.Ascending } }
|
{ sort: { modifiedOn: SortingOrder.Ascending } }
|
||||||
)
|
)
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
let commentMode = false
|
||||||
|
|
||||||
|
$: if (commentMode) {
|
||||||
|
dispatch('tooltip', { kind: 'popup' })
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -50,6 +55,14 @@
|
|||||||
use:resizeObserver={() => {
|
use:resizeObserver={() => {
|
||||||
dispatch('changeContent')
|
dispatch('changeContent')
|
||||||
}}
|
}}
|
||||||
|
on:keydown={(evt) => {
|
||||||
|
console.log(evt)
|
||||||
|
if (commentMode) {
|
||||||
|
evt.preventDefault()
|
||||||
|
evt.stopImmediatePropagation()
|
||||||
|
closeTooltip()
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div class="fs-title mr-2">
|
<div class="fs-title mr-2">
|
||||||
<Label label={chunter.string.Comments} />
|
<Label label={chunter.string.Comments} />
|
||||||
@ -73,7 +86,12 @@
|
|||||||
</div>
|
</div>
|
||||||
{#if withInput}
|
{#if withInput}
|
||||||
<div class="max-w-120 input">
|
<div class="max-w-120 input">
|
||||||
<CommentInput {object} />
|
<CommentInput
|
||||||
|
{object}
|
||||||
|
on:focus={(evt) => {
|
||||||
|
commentMode = true
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user