Repository navigation
[EuiFlyout] Refactor polymorphic types - #4940
Merged
Merged
Conversation
Contributor
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4940/ |
thompsongl
marked this pull request as ready for review
July 7, 2021 20:44
Contributor
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4940/ |
Contributor
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4940/ |
chandlerprall
approved these changes
Jul 13, 2021
chandlerprall
left a comment
Contributor
There was a problem hiding this comment.
Nice!! Tested locally by throwing different as+attribute combinations and it errors when expected, and works when expected.
Contributor
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4940/ |
This was referenced Jul 20, 2021
Closed
11 tasks done
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
We've tried a couple different approaches to solve the type problem in EuiFlyout, which is polymorphic (uses an
asprop to set the underlying element), has an inferred type generic, and usesReact.forwardRef.React.forwardRefinterferes with the more correct types set via the prop type interface(s) and (without tradeoffs) will cause one of the following problems:hrefcan be used on anything)hrefcan't be used even on ana)We had "solved" this by curating a manual list of accepted HTML elements and creating a type from those. Working on adding Emotion, a new problem arose: the type idiosyncrasies prevent Emotion from appending the
cssprop, causing errors.This PR changes the types again using targeted casting to get the flexibility we want while getting strict prop type checking for various elements. Also checked the changes against Kibana.
Also relevant to #4416
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Checked in Chrome, Safari, Edge, and Firefox- [ ] Props have proper autodocs and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for the any docs examples- [ ] Added or updated jest tests- [ ] Checked for accessibility including keyboard-only and screenreader modes