Form ignores Styled refinements such as gap_5()
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in crates/component/src/form/form.rs at Form::render and compare it with Field's style handling. Reproduce the issue with the provided v_form().gap_5() example, then verify that caller-supplied spacing, padding, and background refinements affect the rendered form while its built-in layout still works.
Written by the indexing model from the issue text.
Description
Description
Form implements Styled and stores style refinements in its style field, but Form::render never applies self.style to the rendered element. As a result, style helpers called directly on v_form()/h_form(), such as .gap_5(), .p_5(), and .bg(...), are silently ignored.
This affects gpui-component 0.6.1 and is also present on the current main branch:
https://github.com/longbridge/gpui-kit/blob/main/crates/component/src/form/form.rs#L119-L150
Environment
- GPUI (
gpui-pre): v0.3.4 - GPUI Component: v0.6.1
- Platform: Windows 11, build 26100
- Rust: 1.98.1
Steps to Reproduce
v_form()
.gap_5()
.child(field().child(div().child("One")))
.child(field().child(div().child("Two")))
Other Styled methods applied directly to Form, for example .p_5() or .bg(rgb(0xff0000)), are ignored as well.
Expected
The fields should have the spacing requested by .gap_5() (20 px with the default rem size), and other style refinements should be applied to the rendered form container.
Actual
The form keeps its built-in vertical gap (8 px for the default size), regardless of .gap_5(). Other externally supplied style refinements are also discarded.
Styled::style() writes into Form::style:
impl Styled for Form {
fn style(&mut self) -> &mut StyleRefinement {
&mut self.style
}
}
However, Form::render() builds and returns a new v_flex() without calling refine_style(&self.style). Other styled components, including Field, apply their stored refinement this way.
A possible fix is to apply the form refinement after its built-in layout defaults so caller-provided styles can override them:
v_flex()
// built-in form layout...
.refine_style(&self.style)
- Dominant language
- Rust
- Stars
- 14.5k
- Forks
- 897
- Avg merge
- 13h 22m
- Merged PRs (30d)
- 247
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from longbridge/gpui-kit
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
longbridge/gpui-kit#2877 · 1 comment ·
-
sidebar
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
longbridge/gpui-kit#1818 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
longbridge/gpui-kit#3158 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
longbridge/gpui-kit#3157 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
longbridge/gpui-kit#3156 · 1 comment ·
All issues in longbridge/gpui-kit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100