-
Notifications
You must be signed in to change notification settings - Fork 323
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
Some drop down fixes #10337
Merged
Merged
Some drop down fixes #10337
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2f4858
Fix multiple arrows
farmaazon 87f78ac
Fix drop-down problem with widget number
farmaazon e3ea8b7
Merge branch 'develop' of github.com:enso-org/enso into wip/farmaazon…
farmaazon f262130
changelog
farmaazon 013bb11
Apply @kazcw review
farmaazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ import SizeTransition from '@/components/SizeTransition.vue' | |
import SvgIcon from '@/components/SvgIcon.vue' | ||
import DropdownWidget, { type DropdownEntry } from '@/components/widgets/DropdownWidget.vue' | ||
import { unrefElement } from '@/composables/events' | ||
import { provideSelectionArrow } from '@/providers/selectionArrow.ts' | ||
import { defineWidget, Score, WidgetInput, widgetProps } from '@/providers/widgetRegistry' | ||
import { injectSelectionArrow, provideSelectionArrow } from '@/providers/selectionArrow.ts' | ||
import { Score, WidgetInput, defineWidget, widgetProps } from '@/providers/widgetRegistry' | ||
import { | ||
multipleChoiceConfiguration, | ||
singleChoiceConfiguration, | ||
|
@@ -27,7 +27,7 @@ import { arrayEquals } from '@/util/data/array' | |
import type { Opt } from '@/util/data/opt' | ||
import { qnLastSegment, tryQualifiedName } from '@/util/qualifiedName' | ||
import { autoUpdate, offset, shift, size, useFloating } from '@floating-ui/vue' | ||
import { computed, proxyRefs, ref, type ComponentInstance, type RendererNode } from 'vue' | ||
import { computed, proxyRefs, ref, watch, type ComponentInstance, type RendererNode } from 'vue' | ||
|
||
const props = defineProps(widgetProps(widgetDefinition)) | ||
const suggestions = useSuggestionDbStore() | ||
|
@@ -221,6 +221,8 @@ const innerWidgetInput = computed<WidgetInput>(() => { | |
} | ||
}) | ||
|
||
const parentSelectionArrow = injectSelectionArrow(true) | ||
const suppressArrow = ref(false) | ||
provideSelectionArrow( | ||
proxyRefs({ | ||
id: computed(() => { | ||
|
@@ -231,17 +233,36 @@ provideSelectionArrow( | |
if (node instanceof Ast.AutoscopedIdentifier) return node.identifier.id | ||
if (node instanceof Ast.PropertyAccess) return node.rhs.id | ||
if (node instanceof Ast.App) node = node.function | ||
else break | ||
else { | ||
const wrapped = node.wrappedExpression() | ||
if (wrapped != null) node = wrapped | ||
else break | ||
} | ||
} | ||
return null | ||
}), | ||
requestArrow: (target: RendererNode) => { | ||
arrowLocation.value = target | ||
}, | ||
handled: false, | ||
get suppressArrow() { | ||
return suppressArrow.value | ||
}, | ||
set suppressArrow(value) { | ||
suppressArrow.value = value | ||
}, | ||
}), | ||
) | ||
|
||
watch( | ||
() => isHovered.value && !suppressArrow.value, | ||
(suppressParentsArrow) => { | ||
if (parentSelectionArrow) { | ||
parentSelectionArrow.suppressArrow = suppressParentsArrow | ||
} | ||
}, | ||
) | ||
|
||
const isMulti = computed(() => props.input.dynamicConfig?.kind === 'Multiple_Choice') | ||
const dropDownInteraction = WidgetEditHandler.New('WidgetSelection', props.input, { | ||
cancel: () => {}, | ||
|
@@ -318,6 +339,7 @@ function toggleVectorValue(vector: Ast.MutableVector, value: string, previousSta | |
function expressionTagClicked(tag: ExpressionTag, previousState: boolean) { | ||
const edit = graph.startEdit() | ||
const tagValue = resolveTagExpression(edit, tag) | ||
console.log('expressionTagClicked', tagValue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug logging (here and 1 below) |
||
if (isMulti.value) { | ||
const inputValue = props.input.value | ||
if (inputValue instanceof Ast.Vector) { | ||
|
@@ -332,6 +354,7 @@ function expressionTagClicked(tag: ExpressionTag, previousState: boolean) { | |
props.onUpdate({ edit, portUpdate: { value: vector, origin: props.input.portId } }) | ||
} | ||
} else { | ||
console.log('Updating widget', tagValue) | ||
props.onUpdate({ edit, portUpdate: { value: tagValue, origin: props.input.portId } }) | ||
} | ||
} | ||
|
@@ -399,9 +422,9 @@ declare module '@/providers/widgetRegistry' { | |
must be already in the DOM when the <Teleport> component is mounted. | ||
So the Teleport itself can be instantiated only when `arrowLocation` is already available. --> | ||
<Teleport v-if="arrowLocation" :to="arrowLocation"> | ||
<SvgIcon v-if="isHovered" name="arrow_right_head_only" class="arrow" /> | ||
<SvgIcon v-if="isHovered && !suppressArrow" name="arrow_right_head_only" class="arrow" /> | ||
</Teleport> | ||
<SvgIcon v-else-if="isHovered" name="arrow_right_head_only" class="arrow" /> | ||
<SvgIcon v-else-if="isHovered && !suppressArrow" name="arrow_right_head_only" class="arrow" /> | ||
<Teleport v-if="tree.nodeElement" :to="tree.nodeElement"> | ||
<SizeTransition height :duration="100"> | ||
<DropdownWidget | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { createContextStore } from '@/providers' | |
import type { PortId } from '@/providers/portInfo.ts' | ||
import type { AstId, TokenId } from '@/util/ast/abstract.ts' | ||
import { identity } from '@vueuse/core' | ||
import type { RendererElement } from 'vue' | ||
import type { Ref, RendererElement } from 'vue' | ||
|
||
interface SelectionArrowInfo { | ||
/** Id of the subexpression that should display arrow underneath. */ | ||
|
@@ -12,6 +12,10 @@ interface SelectionArrowInfo { | |
/** Whether or not the arrow provided by this context instance was already requested. | ||
* Do not request the arrow twice, it will be stolen from other elements! */ | ||
handled: boolean | ||
/** | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docs |
||
*/ | ||
suppressArrow: boolean | ||
} | ||
|
||
export { injectFn as injectSelectionArrow, provideFn as provideSelectionArrow } | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this in a computed
showArrow
to use here and in thev-if
/v-else-if
would ensure that if our logic for when to show the arrow changes, it is still consistent with when we inhibit a parent arrow.