[base-ui] POC: Input using component-per-node pattern #40893
Closed
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.
This is a POC of using the component per DOM element pattern for the Input component.
I created a new component, Textbox, as I didn't want to fix all the usages of the existing Input in order to build the site. The Textbox is basically the Input broken down into individual components.
I simplified the implementation by removing the multiline logic. This was only to speed up the work by not having to deal with generics and refs pointing to either an input or a textarea. Having multiple components doesn't necessarily make it easier or harder to work with union props, but since this wasn't the main goal of this POC, I didn't want to waste too much time.
For the component replacement/customization API, I chose to use render props.
A few observations I had:
Preview: https://deploy-preview-40893--material-ui.netlify.app/experiments/base/component-per-node/
Usage: https://github.com/michaldudak/material-ui/blob/poc/input-component-per-node/docs/pages/experiments/base/component-per-node.tsx