Git Product home page Git Product logo

Comments (12)

ctron avatar ctron commented on July 21, 2024 1

This should be fixed with c33dcb6

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

Yup, IIRC that was fixed just recently. One of the buttons was missing the type="button" attribute.

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

Ah no, same issue I guess, but different component: #42

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

There should be a fix on main (which uses PF5 now) or on release-0.4.x (for PF4).

from patternfly-yew.

collinsmarra avatar collinsmarra commented on July 21, 2024

I have been migrating and I am having to change lots of things. I am not sure if SubmitEvent not actually works.
For Example:

    let onsubmit = {
        let local_errors = local_errors;
        let (state, dispatch) = (login_state.clone(), dispatch);
        Callback::from(move |event: SubmitEvent| {
            event.prevent_default();
            let state = state.clone();
            let local_errors = local_errors.clone();
            let (email, password, dispatch) = (
                state.email.clone(),
                state.password.clone(),
                dispatch.clone(),
            );
            wasm_bindgen_futures::spawn_local(async move {
                let response = login(&email, &password).await;
                let local_errors = local_errors.clone();
                match response {
                    Ok(response) => {
                        // FIXME: set cookie
                        redirect_page("/pages/display".to_string());
                    }
                    Err(err) => {
                        // web_sys::console::log_1(&JsValue::from_str(&err.description.to_string()));
                            let mut data = local_errors.deref().clone();
                            data.message = err.message.clone();
                            data.description = err.description.clone();
                            local_errors.set(data);

                    }
                }
            })
        })
    };

    html! {
        <>
            <Background />
            {error_handler}
                <Login>
                    <LoginMain>
                        <LoginMainHeader title={title} description="Enter Credentials to login to your account"/>
                            <LoginMainBody>
                                <Form onsubmit={onsubmit}>
                                    <FormGroup label="Email">
                                        <TextInput 
                                            required=true name="email" r#type={TextInputType::Email}
                                            value={(*login_state.email).to_string().clone()}
                                            onchange={oninput_email} />
                                    </FormGroup>
                                    <FormGroup label="Password">
                                        <TextInput 
                                            required=true name="password" r#type={TextInputType::Password} 
                                            value={(*login_state.password).to_string().clone()}
                                            onchange={oninput_password}/>
                                    </FormGroup>
                                    <ActionGroup>
                                        <Button label="log in" r#type={ButtonType::Submit} variant={ButtonVariant::Primary} />
                                    </ActionGroup>
                                </Form>
                            </LoginMainBody>
                        <LoginMainFooter links={links} ></LoginMainFooter>
                    </LoginMain>
                </Login>
        </>
    }

from patternfly-yew.

phill-85 avatar phill-85 commented on July 21, 2024

I have been migrating and I am having to change lots of things.

Have you seen this document? Feel free to add or file an issue for anything you think might be missing!

from patternfly-yew.

collinsmarra avatar collinsmarra commented on July 21, 2024

@phill-85 thanks, but I managed to migrate most of the things, there is just an issue with OnSubmit

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

there is just an issue with OnSubmit

What's the issue?

from patternfly-yew.

collinsmarra avatar collinsmarra commented on July 21, 2024

when the "log in" button is clicked, the onsubmit callback is not triggered. I could be missing something, but I have checked and rechecked

I have been migrating and I am having to change lots of things. I am not sure if SubmitEvent not actually works. For Example:

    let onsubmit = {
        let local_errors = local_errors;
        let (state, dispatch) = (login_state.clone(), dispatch);
        Callback::from(move |event: SubmitEvent| {
            event.prevent_default();
            let state = state.clone();
            let local_errors = local_errors.clone();
            let (email, password, dispatch) = (
                state.email.clone(),
                state.password.clone(),
                dispatch.clone(),
            );
            wasm_bindgen_futures::spawn_local(async move {
                let response = login(&email, &password).await;
                let local_errors = local_errors.clone();
                match response {
                    Ok(response) => {
                        // FIXME: set cookie
                        redirect_page("/pages/display".to_string());
                    }
                    Err(err) => {
                        // web_sys::console::log_1(&JsValue::from_str(&err.description.to_string()));
                            let mut data = local_errors.deref().clone();
                            data.message = err.message.clone();
                            data.description = err.description.clone();
                            local_errors.set(data);

                    }
                }
            })
        })
    };

    html! {
        <>
            <Background />
            {error_handler}
                <Login>
                    <LoginMain>
                        <LoginMainHeader title={title} description="Enter Credentials to login to your account"/>
                            <LoginMainBody>
                                <Form onsubmit={onsubmit}>
                                    <FormGroup label="Email">
                                        <TextInput 
                                            required=true name="email" r#type={TextInputType::Email}
                                            value={(*login_state.email).to_string().clone()}
                                            onchange={oninput_email} />
                                    </FormGroup>
                                    <FormGroup label="Password">
                                        <TextInput 
                                            required=true name="password" r#type={TextInputType::Password} 
                                            value={(*login_state.password).to_string().clone()}
                                            onchange={oninput_password}/>
                                    </FormGroup>
                                    <ActionGroup>
                                        <Button label="log in" r#type={ButtonType::Submit} variant={ButtonVariant::Primary} />
                                    </ActionGroup>
                                </Form>
                            </LoginMainBody>
                        <LoginMainFooter links={links} ></LoginMainFooter>
                    </LoginMain>
                </Login>
        </>
    }

from patternfly-yew.

collinsmarra avatar collinsmarra commented on July 21, 2024

when the "log in" button is clicked, the onsubmit callback is not triggered. I could be missing something, but I have checked and rechecked

I have been migrating and I am having to change lots of things. I am not sure if SubmitEvent not actually works. For Example:

    let onsubmit = {
        let local_errors = local_errors;
        let (state, dispatch) = (login_state.clone(), dispatch);
        Callback::from(move |event: SubmitEvent| {
            event.prevent_default();
            let state = state.clone();
            let local_errors = local_errors.clone();
            let (email, password, dispatch) = (
                state.email.clone(),
                state.password.clone(),
                dispatch.clone(),
            );
            wasm_bindgen_futures::spawn_local(async move {
                let response = login(&email, &password).await;
                let local_errors = local_errors.clone();
                match response {
                    Ok(response) => {
                        // FIXME: set cookie
                        redirect_page("/pages/display".to_string());
                    }
                    Err(err) => {
                        // web_sys::console::log_1(&JsValue::from_str(&err.description.to_string()));
                            let mut data = local_errors.deref().clone();
                            data.message = err.message.clone();
                            data.description = err.description.clone();
                            local_errors.set(data);

                    }
                }
            })
        })
    };

    html! {
        <>
            <Background />
            {error_handler}
                <Login>
                    <LoginMain>
                        <LoginMainHeader title={title} description="Enter Credentials to login to your account"/>
                            <LoginMainBody>
                                <Form onsubmit={onsubmit}>
                                    <FormGroup label="Email">
                                        <TextInput 
                                            required=true name="email" r#type={TextInputType::Email}
                                            value={(*login_state.email).to_string().clone()}
                                            onchange={oninput_email} />
                                    </FormGroup>
                                    <FormGroup label="Password">
                                        <TextInput 
                                            required=true name="password" r#type={TextInputType::Password} 
                                            value={(*login_state.password).to_string().clone()}
                                            onchange={oninput_password}/>
                                    </FormGroup>
                                    <ActionGroup>
                                        <Button label="log in" r#type={ButtonType::Submit} variant={ButtonVariant::Primary} />
                                    </ActionGroup>
                                </Form>
                            </LoginMainBody>
                        <LoginMainFooter links={links} ></LoginMainFooter>
                    </LoginMain>
                </Login>
        </>
    }

there is just an issue with OnSubmit

What's the issue?

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

I think I can reproduce the issue. Need to check the cause and fix.

from patternfly-yew.

ctron avatar ctron commented on July 21, 2024

Yea, I think I know what the issue is. We started to use AttrValue, as recommended by Yew. However using AttrValue with a default will actually create an attribute with an empty string. Which caused some problems already, especially with the form attribute. Which then points to a form with an empty ID. Which doesn't work.

Switching to Option<AttrValue> solved this issue. And I guess we need to check all the places for exactly that.

from patternfly-yew.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.