-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
admin field width does not work (CSS specificity bug) #7867
Comments
ah yes i'm sorry it seems like the issue is actually something else, and only happens when the widths of a field inside a row add up to 100% {
type: 'row',
fields: [
{
name: 'SKU',
type: 'text',
admin: {
width: '50%',
}
},
{
name: 'taxRate',
type: 'relationship',
relationTo: 'taxes',
hasMany: false,
admin: {
width: '50%',
}
},
]
}, So actually, the fix should be to change from |
Created PR here: #7869 |
Hi @brunocrosier. I still cannot reproduce. Also, if I change Maybe you have some CSS of your own that could be conflicting? |
Hey @GermanJablo which version of payload v3 beta are you using? |
I checked out your PR |
Hmm.. I created my PR via the GitHub UI and I think it branched off of I'm running |
I'm seeing the same issue on beta.94. It is because the css uses "gap". The gap adds space to the row children, so a row with 2 elements of 50% and a gap of 10px calculates out at 100% + 10px, thus overflowing the content. Either switch "width" to "max-width", revert to the previous style with negative margins and padding or set the flex-wrap to nowrap. Here is how the rows where handled in the previous version
|
If you drop this in custom.scss file it has the widths working properly.
|
@brunocrosier Do you want to update your PR to point to the Beta branch? The new path if I'm not mistaken is: Ideally, it would be good to have a test. If that's not possible, I would appreciate if you could do some verifications that flex: 1 doesn't cause any undesired behavior. @tophermurphy thank you for your contribution. Let's first see if @brunocrosier 's solution fixes the problem, since it only changes 1 line of CSS |
Thanks I'll create a new PR pointing at |
I've addressed this issue in this PR now and added some more tests: #7940 Reviews welcome! |
Closes #7867 Problem: currently, setting an ```ts admin: { width: '30%' } ``` does not work for fields inside a row or similar (group, array etc.) Solution: when we render the field, we set a CSS variable `--field-width` with the value of `admin.width`. This allows us to calculate the correct width for a field in CSS by doing `flex: 0 1 var(--field-width);` It also allows us to properly handle `gap` with `flex-wrap: wrap;` Notes: added playwright tests to ensure widths are correctly rendered ![image](https://github.com/user-attachments/assets/0c0f11fc-2387-4f01-9298-a2613fceee22)
🚀 This is included in version v3.0.0-beta.104 |
This issue has been automatically locked. |
Link to reproduction
No response
Payload Version
beta
Node Version
20
Next.js Version
beta
Describe the Bug
This line of CSS is explicitly setting
width: 100%!important
, meaning that when you do something likealthough the
width: 50%
is actually set on the element, thewidth: 100%!important
wins out, and we can't have fields of custom widththe
Reproduction Steps
Create a collection and add
The text was updated successfully, but these errors were encountered: