-
Notifications
You must be signed in to change notification settings - Fork 324
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
Extend Selection Menu to allow text selection #11352
base: develop
Are you sure you want to change the base?
Conversation
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.
The isTextDropdown
mode changes a lot of the behavior of the SelectionMenu
; the divergence will only increase in the future--we also have more changes planned for this type of text dropdowns (e.g. filtering mentioned in #11335). As such, instead of adding a new mode to SelectionDropdown
, let's create a new component for text selection dropdowns.
Object.keys(data.value.axis) | ||
.filter((s) => s != 'x') | ||
.map((s) => { | ||
return data.value.axis[s as keyof AxesConfiguration].label | ||
}), |
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.
Since we are using both the keys and the values of data.value.axis
, using Object.entries
might be simpler, and would avoid the type cast.
@@ -14,6 +14,8 @@ const _props = defineProps<{ | |||
title?: string | undefined | |||
labelButton?: boolean | |||
alwaysShowArrow?: boolean | |||
isTextDropdown?: boolean | |||
heading?: string | null |
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.
Not-present (undefined
) or null
would have the same meaning--let's avoid a distinction without a difference.
heading?: string | null | |
heading?: string | undefined |
export interface SelectionMenu { | ||
selected: Ref<string> | ||
title?: string | ||
options: Record<string, SelectionMenuOption> | ||
isTextDropdown?: boolean | ||
heading?: string | ||
} |
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.
Instead of the isTextDropdown
field, let's introduce a separate type:
export interface TextSelectionMenu {
type: 'textSelectionMenu'
selected: Ref<string>
title?: string
options: Record<string, TextSelectionMenuOption>
heading?: string
}
The reason for the type
field approach is probably not apparent--it fits into my plan for the ToolbarItem
types (as we add more and their definitions get more complex):
Eventually, every type will have a type
field that must contain a specific value if present; however, the field will be optional for any type that can be recognized by its fields, to allow concise toolbar definitions.
So far, every type has had distinctive enough fields that we haven't needed to make any type
fields required (and I haven't got around to defining optional type
fields). The new TextSelectionMenu
has similar fields to the normal SelectionMenu
, so its type
field is not optional.
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.
ok! Thanks, I wasn't sure if it was best to adapt the current dropdown or make a new one so I'll separate it now!
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.