Git Product home page Git Product logo

Comments (6)

miroslavstastny avatar miroslavstastny commented on May 18, 2024 1

Yes, adding href to handledProps in MenuItem is my plan.
@levithomason - any strong reason against removing if (props.href) return 'a' from getElementType()?

from fluent-ui-react.

miroslavstastny avatar miroslavstastny commented on May 18, 2024

getElementType() takes getDefault parameter but renderComponent() never sets that. There is no way how a Component could override that.
@levithomason, @mnajdova, @kuzhelov - before stardust-ui/react-old#21 there was such a possibility. Can we add it back?

from fluent-ui-react.

kuzhelov avatar kuzhelov commented on May 18, 2024

Agree that using getDefaultparameter of getElementType() function might be a first step to resolve this problem.

At the same time, the following line of getElementType seems like a black magic to me:

// ----------------------------------------
// infer anchor links

if (props.href) return 'a'

Where this functionality might come in need? It seems to be always possible for a client to specify as='a' alongside with href, so that desired effect would be achieved - and achieved with reasonable explicitness. And the fact that in case of href being specified component type suddenly changes its dress to appear as a - this is really weird and unexpected thing to me (at least certainly for those cases where component's as value is specified in its defaultProps).

So, my suggestion would be to avoid this 'implicit "a"', and as further steps - introduce href as handled prop of MenuItem, so that component will take care of where this attribute should be plaved in its components' tree:

// MenuItem
 renderComponent({ ElementType, classes, accessibility, rest }) {
    const { children, content, icon, href } = this.props

    const hasChildren = childrenExist(children)

    return (
      <ElementType ... href={hasChildren ? href : undefined} {...rest}>
        { hasChildren ? children
         : (
          <a href={href} ... >
          ...
          </a>
        )}
      </ElementType>
    )
  }

from fluent-ui-react.

levithomason avatar levithomason commented on May 18, 2024

delete it 👍

from fluent-ui-react.

jurokapsiar avatar jurokapsiar commented on May 18, 2024

on top of what was mentioned, all attributes relevant to the <a> need to be rendered on the anchor - href, rel, target, ...

from fluent-ui-react.

miroslavstastny avatar miroslavstastny commented on May 18, 2024

Fixed by #323

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.