GithubHelp home page GithubHelp logo

Comments (3)

jugglingcats avatar jugglingcats commented on June 10, 2024

Have same issue. Would love to know if it's a bug or user error on my part.

from fluent-ui-react.

jugglingcats avatar jugglingcats commented on June 10, 2024

I managed to find a workaround (for my use case anyway) by supplying itemToString. My code:

export const FrameSelector = () => {
    const items = [
        <div key="item1" placeholder="Item 1" style={{marginLeft: "10px"}}>Item 1</div>,
        "Item 2"
    ];

    function itemToString(value) {
        const placeholder = value && value.props && value.props.placeholder;
        return placeholder || "PLACEHOLDER NOT PROVIDED";
    }

    return <Dropdown itemToString={itemToString} items={items}/>
};

My goal is simply to indent some items to make the dropdown look tree-like. I don't know if the above is best practice but it serves my purpose.

I realise re-reading the OP issue that mine is not quite the same, since my content is an element with style, but it may still be a solution to the original issue.

However, I notice that my solution does not correctly select the default value, if given:

    return <Dropdown itemToString={itemToString} items={items} defaultValue="Item 1"/>

This correctly displays "Item 1" in the trigger button but when dropdown is opened the second item is highlighted not the first.

from fluent-ui-react.

KyleBastien avatar KyleBastien commented on June 10, 2024

@jugglingcats Thanks for the tip on itemToString, that got me closer (sort of..) and I ended up with this:

https://codesandbox.io/s/fluent-ui-example-wo34b

The issue I'm running into now is that the active property doesn't seem to be respected, and I'm able to select items even if it's set to active: false.

from fluent-ui-react.

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.