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

Accept input when clicking off the component #11541

Merged
merged 2 commits into from
Nov 13, 2024
Merged
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
28 changes: 20 additions & 8 deletions app/gui/src/project-view/components/ComponentBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useProjectStore } from '@/stores/project'
import { useSuggestionDbStore } from '@/stores/suggestionDatabase'
import { type Typename } from '@/stores/suggestionDatabase/entry'
import type { VisualizationDataSource } from '@/stores/visualization'
import { cancelOnClick, isNodeOutside, targetIsOutside } from '@/util/autoBlur'
import { isNodeOutside, targetIsOutside } from '@/util/autoBlur'
import { tryGetIndex } from '@/util/data/array'
import type { Opt } from '@/util/data/opt'
import { Rect } from '@/util/data/rect'
Expand Down Expand Up @@ -77,17 +77,29 @@ const clickOutsideAssociatedElements = (e: PointerEvent) => {
false
: props.associatedElements.every((element) => targetIsOutside(e, element))
}
const cbOpen: Interaction = cancelOnClick(clickOutsideAssociatedElements, {
cancel: () => emit('canceled'),
const cbOpen: Interaction = {
pointerdown: (e: PointerEvent) => {
if (clickOutsideAssociatedElements(e)) {
if (props.usage.type === 'editNode') {
acceptInput()
} else {
emit('canceled')
}
}
return false
},
cancel: () => {
emit('canceled')
},
end: () => {
// In AI prompt mode likely the input is not a valid mode.
if (input.mode.mode !== 'aiPrompt') {
acceptInput()
} else {
// In AI prompt mode, the input is likely not a valid expression.
if (input.mode.mode === 'aiPrompt') {
emit('canceled')
} else {
acceptInput()
}
},
})
}

function scaleValues<T extends Record<any, number>>(
values: T,
Expand Down
Loading