Fix type/PK -> type/Name and type/FK field remapping in the QB#45047
Fix type/PK -> type/Name and type/FK field remapping in the QB#45047
type/PK -> type/Name and type/FK field remapping in the QB#45047Conversation
bshepherdson
left a comment
There was a problem hiding this comment.
These changes look sensible to me.
|
| `:internal`." | ||
| [dimensions] | ||
| (when-let [dimension (m/find-first (fn [dimension] | ||
| (#{"external" "internal"} (object-get dimension "type"))) |
There was a problem hiding this comment.
dimension is a CLJS map here, not JS object; that's why all object-get calls return nil
type/FK field remapping in the QB
| skip: | ||
| fieldId === searchFieldId || | ||
| selectedValues.length === 0 || | ||
| searchValue.length !== 0, |
There was a problem hiding this comment.
Is this to avoid CLS while user is typing? Or to optimize?
Definitely deserves a comment.
But maybe we don't need it?
| ); | ||
|
|
||
| const options = useMemo(() => getFieldOptions(fieldValues), [fieldValues]); | ||
| const options = useMemo( |
There was a problem hiding this comment.
Sometimes remapped values turn back to raw values.
In the video I'm using commas to apply subsequent values.
2024-07-11.16-58-45.mp4
There was a problem hiding this comment.
2024-07-11.17-13-53.mp4
There was a problem hiding this comment.
^ native inputs are not changed here, it's a different component
There was a problem hiding this comment.
@kamilmielnik the only reason I can think of why values can turn into raw values:
- search response -> pick value
- we can remap the value because search results are still here
- we send a new remapping request to the newly selected values
- you start typing something new
- there is a new search response
- if the search response becomes available before the remapping response, in this interval you would see unmapped values
I might be able to fix this but this would make the implementation really really much more difficult.
There was a problem hiding this comment.
OK, I made it out of scope of this PR. I cannot make it work cleanly after several days. Please take a look again, and read the PR description again.
| }); | ||
|
|
||
| describe("type/PK -> type/Name remapping (metabase#45063)", () => { | ||
| it("should work with questions", () => { |
There was a problem hiding this comment.
Should we assert metrics as well?
There was a problem hiding this comment.
Metrics are going to be reworked soon. It's better not to test them right now
| }); | ||
| }); | ||
|
|
||
| describe("issue 45063", () => { |
There was a problem hiding this comment.
there is - you can actually find values
There was a problem hiding this comment.
Let's add a (metabase#7231) tag somewhere (cy.log?) for it.
Also for #37955
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 7e6adfa...1b81e26.
|
| @@ -787,15 +787,16 @@ | |||
| (mu/defn ^:private remapped-field :- [:maybe ::lib.schema.metadata/column] | |||
There was a problem hiding this comment.
PK values are not remapped to type/Name fields. But we allow searching by Name. That's why remapped-field checks for FKs only and is effectively unchanged.
kamilmielnik
left a comment
There was a problem hiding this comment.
FE code looks good, approving.
Please consider the UX suggestion 🙏
Note that selected values are displayed as raw values and this is out of scope for this PR.
Do we have this reported as a separate issue?
| }); | ||
| }); | ||
|
|
||
| describe("issue 45063", () => { |
There was a problem hiding this comment.
Let's add a (metabase#7231) tag somewhere (cy.log?) for it.
Also for #37955
| const searchOptions = canSearch ? getFieldOptions(fieldValues) : []; | ||
| const visibleOptions = getFilteredOptions( | ||
| searchOptions, | ||
| searchValue, | ||
| selectedValues, | ||
| ); |
There was a problem hiding this comment.
I'm not confident it's a good idea to have FE-side filtering on top of BE-side filtering.
I see where this is coming from but it makes for a bad UX in some of the cases.
I tried it without getFilteredOptions and I think it works way more smooth this way.
Please consult product/design team if you disagree.
There's an annoying flicker of dropdown content on subsequent searches (but not the first one).
Fixes #45063
Fixes #7231
Fixes #37955
BE changes:
name_fieldfor query metadata.MBQL lib API changes:
dimensionsparsing. This makesexternal, i.e.type/FKremapping work out of the box.type/PK->type/Namefield remapping work.FE changes:
SearchValuePickerhandle mixed remapping options. Adds loading state.How to verify type/PK -> type/Name remapping:
People.NameEntity Namesemantic type is setFiltering on this fieldforPeople.IDtoA list of all valuesPeopletable. Click onID-> Filter on this column. You should see a list of remapped values.Filtering on this fieldforPeople.IDtoSearch boxPeopletable. Click onID-> Filter on this column. Start typing some name. You should get autocomplete. Please note that the placeholderSearch by IDis misleading and this is something that we need to fix separately.How to verify type/FK -> column remapping:
Orders.Product ID-> ClickUse original value->Use foreign key-> SelectProducts.Title.Filtering on this fieldtoA list of all valuesOrderstable. Click onProduct ID-> Filter on this column. You should see a list of product names.Search box.