-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Form lib] Get ready for v1.0.0 #65654
Comments
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
@sebelga Thanks for sharing your plan for moving forward. This looks pretty clear to me. I have a few questions:
|
I've thought about it and I don't share your concern. During a very short period of time, there will be 2 copies of the testbed utils in master. This allows me to move forward with the most important task, which is to merge asap #64647 without delaying it further. There won't be time for confusion as the next PR will be to remove the x-pack copy and point to the es_ui_shared folder.
It means that I'd like to merge PR 1 asap and not wait to have complete test coverage of the lib to do it. The lib has already some good coverage and I prefer to put this work on pause and focus on getting the PR ready to be merged. I will complete in PR 3.
Great point, although that would be a totally different work. Removing the override means touching/refactoring different pieces of code (the lib but also the request hook I guess) so this should be done in a separate PR.
There are many places where it would be useful and more convenient for code readability. One of them is here: Instead of the whole subscription block + the export const PipelineTestFlyoutProvider: React.FunctionComponent<Props> = ({ closeFlyout }) => {
const form = useFormContext();
const formData = useFormData();
// Or...
// const formData = form.useData();
return (
<PipelineTestFlyout
pipeline={formData}
closeFlyout={closeFlyout}
isPipelineValid={form.isValid}
/>
);
}; |
@sebelga I had one suggestion :) What do you think about updating form updates ( Not sure what the implications might be for performance but I think it would simplify consumer code to: async function myCoolListener ({ validate, data }) => { if (await validate()) {...} else {...} } I might be missing a case that |
@jloleysens Why force the consumer to call a function if we can provide him with the necessary boolean? Also, the current API already allows you to do the above if the consumer prefers it. I wouldn't recommend this though as the whole point of having 3 states (undefined, false, true) is what brings performance to the lib. We don't need to validate all the fields each time a user hits a keystroke on 1 field. The normal flow we expect a user to have
Also, your suggestion requires that each consumer declare a separate state to keep track of form validity (to be able to toggle a button const [isMyFormValid, setIsMyFormValid] = useState<boolean | undefined>(undefined); It adds complexity to the consumer that I don't think is necessary as we already know that information. |
While working on adding test coverage for the form library I discovered a few issues with a high impact on the consuming code. I found a memory leak problem that allowed me to fix a data flow problem.
This implied that I had to go and fix the consuming code (mainly the mappings editor) and do some refactor in places where we used some hacks in the mappings editor "to make it work".
These discoveries are very welcome and put the form library in much better shape for consumers. This also means that the "Add tests to the form lib" task that I had planned is now much bigger and this meta issue will serve to communicate how I plan to proceed to get the form lib to a
v1.0.0
stable version (solid architecture, high-quality test coverage, good README.md and obviously all bug fixes).v1.0.0
PR 1 ([form lib] Fix issues + add test coverage #64647)
es_ui_shared
to be bale to use it in OSSPR 2 ([test_utils/Testbed] Move to src/test_utils folder (OSS) #66898)
es_ui_shared
copy made in PR 1PR 3
PR 4
useForm
anduseField
hook to memoized the objects returned and be able to properly declare theform
object in the consumeruseEffect
dependency array.PR 5 (
v1.0.0
)v1.1.0
v1.1.0
)useFormData(<ArrayOfPathsToWatch>)
hook to the library. This will allow consumers to get updates of the form data without the need of the<FormDataProvider>
.Depending on the use case, one will be more suited than the other. If the whole component is wrapped by a
<FormDataProvider>
, then theuseFormData(['someField'])
hook would make more sense. If there is a lot of JSX in the component and only a small part of it needs to react to form updates, then<FormDataProvider>
makes more sense.The text was updated successfully, but these errors were encountered: