fix(styled-props): forward flex props to components (closes #1543)#3340
Open
Mrsandeep27 wants to merge 1 commit intorazorpay:masterfrom
Open
fix(styled-props): forward flex props to components (closes #1543)#3340Mrsandeep27 wants to merge 1 commit intorazorpay:masterfrom
Mrsandeep27 wants to merge 1 commit intorazorpay:masterfrom
Conversation
…onents Adds `flex`, `flexGrow`, `flexShrink`, `flexBasis` to the `StyledPropsBlade` type and the `makeStyledProps` allowlist. Before this change, passing `<Button flex="1" />` or `<TextInput flex="1" />` inside a flex Box container was silently dropped — `getStyledProps` filtered out `flex` because it wasn't in the whitelist — so the children did not split the available width equally. Closes razorpay#1543 Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c311c9b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c311c9b:
|
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.
Context / Motivation
Fixes #1543.
Before this change, passing
flex/flexGrow/flexShrink/flexBasisto Blade components likeButtonorTextInputinside a flex container had no effect:Root cause:
StyledPropsBlade(packages/blade/src/components/Box/BaseBox/types/propsTypes.ts) picked only'alignSelf' | 'justifySelf' | 'placeSelf' | 'order' | 'flexWrap'fromFlexboxProps, and themakeStyledPropsallowlist (packages/blade/src/components/Box/styledProps/getStyledProps.ts) didn't include the flex item properties either. SogetStyledProps(rest)silently droppedflex,flexGrow, etc. before they reached the component's outer wrapper.Changes
flex,flexGrow,flexShrink,flexBasisto theStyledPropsBladetype.makeStyledPropsso they flow throughgetStyledProps/useStyledProps.Scope kept minimal on purpose:
width/height/minWidth/maxWidth/minHeight/maxHeightto styled props.BaseButtoncomputes its own internalwidth/heightfor icon-only buttons (viagetProps) and passes them toStyledBaseButton; adding these to styled props now would require carefully ordering the spread on every component and is best done as a follow-up.defaultStyledPropsObject = makeStyledProps({})instorybookArgTypes.tsauto-picks up the new props for Storybook docs.Test plan
yarn workspace @razorpay/blade buildpasses (type check includes the new properties)flex,flexGrow,flexShrink,flexBasiscontrols appear and applyingflex="1"to the exampleButtonmakes it stretch inside a flexBox.Checklist
.changeset/styled-props-flex-support.md,patch)StyledPropsBladeupdatedmakeStyledPropsallowlist updated🤖 Generated with Claude Code