Repository navigation
fix(Field): accept accessor chains as help and label - #1334
Merged
Merged
Conversation
Field and LabeledContainer treated any value with a truthy isComponentType as a widget class. An accessor chain returns another accessor for every property, so it was taken for a class and rendering crashed. Only isComponentType === true, as set by Component, now counts. Fixes #1333.
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.
Fixes #1333.
Problem
Passing an accessor chain to a field's
helporlabel, or toLabeledContainer'slabel, crashed rendering withins.scheduleExploreIfVisible is not a function:FieldandLabeledContainerdecide whetherhelp/labelis a widget class by checkingisComponentType. An accessor chain returns another accessor for every property read, so that check was truthy and the accessor was used as a widget type.Change
Only
isComponentType === true— the valueComponentsets on every widget class — now counts as a class, inField(help,label) andLabeledContainer(label). Accessor chains fall through to the selector branch and become the text, likebind(...)already did. Passing a widget class, such ashelp={ValidationError}, is unchanged.Tests
New
Field.spec.tsxrenders aTextFieldwith an accessorlabelandhelp, and aLabeledContainerwith an accessorlabel, and checks the text is rendered. All three failed with the crash before the change.yarn workspace cx run test: 538 passing, 2 pending, 0 failingyarn workspace cx run check-types: no errors