From 7f5e05333d8fa2023b21d1b1e62688cdf735a400 Mon Sep 17 00:00:00 2001 From: Oliver Baker Date: Wed, 6 Apr 2022 18:24:07 -0500 Subject: [PATCH] fix(dropdown): added missing props to control the value Tag(s) These include the StyledValueItemTagContainer, props object, ref, and adding the base ValueItemTag along to the exported Dropdown module --- src/components/Dropdown/Dropdown.tsx | 15 +++-- .../__snapshots__/Label.test.tsx.snap | 62 +++++++++++++++---- .../__snapshots__/Spotlight.test.tsx.snap | 6 +- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/src/components/Dropdown/Dropdown.tsx b/src/components/Dropdown/Dropdown.tsx index 4eb3323c4..55453fc31 100644 --- a/src/components/Dropdown/Dropdown.tsx +++ b/src/components/Dropdown/Dropdown.tsx @@ -190,7 +190,7 @@ const PlaceholderContainer = styled(Div)` opacity: 0.8; `; -const StyledTagContainer = styled(Tag.Container)` +const ValueItemTagContainer = styled(Tag.Container)` ${({ dropdownVariant, tagVariant, @@ -225,6 +225,7 @@ export interface DropdownProps { StyledContainer?: StyledSubcomponentType; StyledValueContainer?: StyledSubcomponentType; StyledValueItem?: StyledSubcomponentType; + StyledValueItemTagContainer?: StyledSubcomponentType; StyledOptionsContainer?: StyledSubcomponentType; StyledHiddenOptionsContainer?: StyledSubcomponentType; StyledOptionItem?: StyledSubcomponentType; @@ -236,13 +237,13 @@ export interface DropdownProps { containerProps?: SubcomponentPropsType; valueContainerProps?: SubcomponentPropsType; valueItemProps?: SubcomponentPropsType; + valueItemTagProps?: TagProps; optionsContainerProps?: SubcomponentPropsType; optionItemProps?: SubcomponentPropsType; checkContainerProps?: SubcomponentPropsType; placeholderProps?: SubcomponentPropsType; closeIconProps?: SubcomponentPropsType; arrowIconProps?: SubcomponentPropsType; - valueItemTagProps?: TagProps; containerRef?: React.RefObject; optionsContainerRef?: React.RefObject; @@ -250,6 +251,7 @@ export interface DropdownProps { optionItemRef?: React.RefObject; valueContainerRef?: React.RefObject; valueItemRef?: React.RefObject; + valueItemTagRef?: React.RefObject; checkContainerRef?: React.RefObject; placeholderRef?: React.RefObject; closeIconRef?: React.RefObject; @@ -295,6 +297,7 @@ const Dropdown = ({ StyledContainer = Container, StyledValueContainer = ValueContainer, StyledValueItem = ValueItem, + StyledValueItemTagContainer = ValueItemTagContainer, StyledOptionsContainer = OptionsContainer, StyledHiddenOptionsContainer = HiddenOptionsContainer, StyledOptionItem = OptionItem, @@ -320,6 +323,7 @@ const Dropdown = ({ optionItemRef, valueContainerRef, valueItemRef, + valueItemTagRef, checkContainerRef, placeholderRef, closeIconRef, @@ -408,8 +412,6 @@ const Dropdown = ({ ...placeholderProps, }; - const tagContainerItemProps = valueItemTagProps.containerProps || {}; - // effect to determine if user is scrolling up or down useEffect(() => { if (isOpen && shouldStayInView) { @@ -874,15 +876,15 @@ const Dropdown = ({ .map((val, i, arr) => optionsHash[val] !== undefined ? ( @@ -1001,6 +1003,7 @@ Dropdown.HiddenOptionsContainer = HiddenOptionsContainer; Dropdown.OptionItem = OptionItem; Dropdown.ValueContainer = ValueContainer; Dropdown.ValueItem = ValueItem; +Dropdown.ValueItemTagContainer = ValueItemTagContainer; Dropdown.Placeholder = PlaceholderContainer; export default Dropdown; diff --git a/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap b/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap index e5335e804..06f68e565 100644 --- a/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +++ b/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap @@ -3,8 +3,7 @@ exports[`Label should have asterisk icon if isRequired is true 1`] = ` Object { "asFragment": [Function], - "baseElement": - .c0 { + "baseElement": .c0 { display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -22,7 +21,8 @@ Object { margin-left: 0.25em; } -
+ +
@@ -56,15 +56,33 @@ Object {
, - "container":
+ "container": .c0 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + color: #9FA2A5; + margin-bottom: .25em; + font-size: .75em; +} + +.c1 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + margin-left: 0.25em; +} + +
, - "container":
+ "container": .c0 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + color: #FF4500; + margin-bottom: .25em; + font-size: .75em; +} + +.c1 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + margin-left: 0.25em; +} + +