Feliz.ViewEngine
Feliz.ViewEngine copied to clipboard
Cannot set properties e.g. name and placeholder for Bulma.input.text
When using Bulma.input.text it seems I cannot set properties. Am I doing something wrong here?
Bulma.input.text [
prop.name "theName"
prop.placeholder "a placeholder"
] |> Render.htmlView
// Outputs: <input type="text" class="input"> without 'name' and 'placeholder' properties.
Here's an example test that fails:
[<Fact>]
let ``Test bulma input text has correct properties``() =
// Arrange / Act
let result =
Bulma.input.text [ prop.name "theName"; prop.placeholder "a placeholder" ]
|> Render.htmlView
// Assert
test <@ result = "<input type=\"text\" class=\"input\" name=\"theName\" placeholder=\"a placeholder\">" @>
I can work around this by only using Feliz.ViewEngine and not the Feliz.Bulma.ViewEngine extension:
Html.input [
prop.type'.text
prop.classes [ "input" ]
prop.name "theName"
prop.placeholder "a placeholder"
]
A glance at the source and it seems that the input ElementBuilder is throwing away any props that are not classes. It only calls Helpers.combineClasses while other ElementBuilders seem to use Helpers.partitionClasses and then only combines the classes while keeping the other props.
Maybe it can be fixed by changing
module Input =
let inline propsWithType (cn:string) (typ: IReactProperty) (xs:IReactProperty list) =
Html.input [ typ; Helpers.combineClasses cn xs ]
to this?
module Input =
let inline propsWithType (cn:string) (typ: IReactProperty) (xs:IReactProperty list) =
Html.input [ typ; yield! Helpers.partitionClasses xs ||> (fun c p -> Helpers.combineClasses cn c :: p) ]