-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Relationship field - make sure selected value correctly displays #15553
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
if (touched) { | ||
// @ts-expect-error updateProp doesn't appear to exist, needs investigation |
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.
updateProp
is in the builder store - it's just not typescript at the moment (although Adri has a PR up), I assume that's why it's not happy? But yea it's there at line 41 in the builder store.
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.
ah this is likely the issue - I'll keep note for once this is merged/sorted out!
export let filter: SearchFilter[] | ||
// not really obvious how to type this - some components pass other things here | ||
// but it looks like the component data fetch should only work with tables | ||
export let datasourceType: "table" = "table" |
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.
I think this was added to support the other BB reference types. For example in BBReferenceField
we pass in datasourceType="user"
, and looking at the possible types I think this could either be table
, user
or groupUser
.
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.
So this causes type errors on line 37 with:
$: fetch = fetchData({
API,
datasource: {
type: datasourceType,
tableId: linkedTableId,
},
options: {
filter,
limit: 100,
},
})
This seems to think the only valid datasourceType
is "table"
- I didn't want to fiddle with the typing of data fetching, but something doesn't seem quite right there.
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.
This is a disgusting file hacked by too many people, so well done for successfully making a change - it's not easy. Maybe we'll be able to fully rewrite it at some point, and having TS will make that much easier so thank you!
packages/client/src/components/app/forms/RelationshipField.svelte
Outdated
Show resolved
Hide resolved
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.
LGTM! I don't have a datasource capable of testing this in the product, but code changes look good 👍
Description
If the selected value of a relationship field is not within the first 100 elements then the contents will not be fetched correctly. This PR updates the component to Typescript (as well as performing a very basic conversion of some of the ancillary components in the area) and fetches if the value is not found in the options list.
Fixes: https://linear.app/budibase/issue/BUDI-8998/saved-value-does-not-show-in-select-picker-if-the-value-is-not-in-the
#15400