-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: autocomplete data fields in the editor #4062
Open
jessicamcinchak
wants to merge
22
commits into
main
Choose a base branch
from
jess/data-field-autocomplete
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
48d60ce
wip
jessicamcinchak d0e707e
fix: Autocomplete types
DafyddLlyr 3b2c2c5
Merge branch 'main' of github.com:theopensystemslab/planx-new into je…
jessicamcinchak 76676e5
styled and mostly working x3 component types
jessicamcinchak aa13297
Question options plus ODP enum overrides working
jessicamcinchak 04e19ce
hide popup icon
jessicamcinchak e6a8be6
rebase and filter out flag values
jessicamcinchak 949f090
fix add new option
jessicamcinchak cd5f1b8
more component types
jessicamcinchak 5496a47
final component types
jessicamcinchak 6dba5b7
type fix
jessicamcinchak d878159
rebase plus store tests
jessicamcinchak c27fdf1
update e2e placeholders
jessicamcinchak cea734f
try page.locator by id in e2e, placeholder matches multiple elements
jessicamcinchak 8e11f6c
prettier
jessicamcinchak 83e6e3a
try getByRole('combobox')
jessicamcinchak 5114475
fix(e2e): Add click on combobox
DafyddLlyr 867a6c2
set default schema options and remove getFlowSchema()?.nodes calls pe…
jessicamcinchak e57ba7f
fix(e2e): Missing clicks and enters
DafyddLlyr 0e822be
Merge branch 'main' of github.com:theopensystemslab/planx-new into je…
jessicamcinchak a24345a
rebase
jessicamcinchak ec9c832
fix(e2e): Drop index, use last. Match by value without using fill()
DafyddLlyr 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
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 |
---|---|---|
|
@@ -16,6 +16,8 @@ import ErrorWrapper from "ui/shared/ErrorWrapper"; | |
import Input from "ui/shared/Input/Input"; | ||
import InputRow from "ui/shared/InputRow"; | ||
|
||
import { getOptionsSchemaByFn } from "@planx/components/shared/utils"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import { Option } from "../../shared"; | ||
import type { Group } from "../model"; | ||
import ChecklistOptionsEditor from "./OptionsEditor"; | ||
|
@@ -28,6 +30,10 @@ export const Options: React.FC<{ formik: FormikHookReturn }> = ({ formik }) => { | |
|
||
const exclusiveOrOptionManagerShouldRender = | ||
hasFeatureFlag("EXCLUSIVE_OR") && nonExclusiveOptions.length; | ||
|
||
const schema = useStore().getFlowSchema()?.options; | ||
const initialOptions: Option[] | undefined = formik.initialValues.options || formik.initialValues.groupedOptions?.map((group: Group<Option>) => group.children)?.flat(); | ||
const initialOptionVals = initialOptions?.map((option) => option.data?.val); | ||
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. This is a bit of a lazy rebase right now while the exclusive-or work is still in-progress - I think |
||
|
||
return ( | ||
<ModalSectionContent subtitle="Options"> | ||
|
@@ -115,6 +121,7 @@ export const Options: React.FC<{ formik: FormikHookReturn }> = ({ formik }) => { | |
groups: formik.values.groupedOptions.map( | ||
(opt: Group<Option>) => opt.title | ||
), | ||
schema: getOptionsSchemaByFn(formik.values.fn, schema, initialOptionVals), | ||
}} | ||
/> | ||
</Box> | ||
|
@@ -160,7 +167,10 @@ export const Options: React.FC<{ formik: FormikHookReturn }> = ({ formik }) => { | |
}) as Option | ||
} | ||
Editor={ChecklistOptionsEditor} | ||
editorExtraProps={{ showValueField: !!formik.values.fn }} | ||
editorExtraProps={{ | ||
showValueField: !!formik.values.fn, | ||
schema: getOptionsSchemaByFn(formik.values.fn, schema, initialOptionVals), | ||
}} | ||
/> | ||
)} | ||
{exclusiveOrOptionManagerShouldRender ? ( | ||
|
@@ -189,7 +199,10 @@ export const Options: React.FC<{ formik: FormikHookReturn }> = ({ formik }) => { | |
}) as Option | ||
} | ||
Editor={BaseOptionsEditor} | ||
editorExtraProps={{ showValueField: !!formik.values.fn }} | ||
editorExtraProps={{ | ||
showValueField: !!formik.values.fn, | ||
schema: getOptionsSchemaByFn(formik.values.fn, schema, initialOptionVals), | ||
}} | ||
/> | ||
</ErrorWrapper> | ||
</Box> | ||
|
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
Oops, something went wrong.
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.
required
data field are not being correctly populated - I've tried a couple iterations here, but still not landed on the right solution.Opening for wider review in the meantime and any pointers very welcome!
Here's what I've tried so far:
"Data Field"
to"Data field"
, butgetByPlaceholder()
will now match more than one element (MUI Autocompletes have many nested elements)"getByRole("combobox", { name: "Data field" })
should exclusively be matching theinput
elementpopupIcon
arrow is disabled, so there's no dropdown of options to.click()
or open/expand - but I'm guessing I'm still using the wrong combo of.fill
/.click
here to mimic typing input ??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 working for me locally - 5114475
Running on CI now 🤞
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.
It failed on some still - to be fair I didn't run them all locally just the first few. Will pick this up again but I think adding the
.click()
is what we're after.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.
Appreciate second eyes on this - it's a tedious tricky one! Once one node with a data field is successfully added, then future ones will have suggested schema options - so might require combination of
fill
&click
?