Giter Club home page Giter Club logo

Comments (5)

nowseemee avatar nowseemee commented on May 25, 2024 1

Hi @christopherGdynia, thanks for reporting this issue - it really seems like the href property is not drilled down to the child component: #363

from scale.

christopherGdynia avatar christopherGdynia commented on May 25, 2024 1

Thanks for your answers :)

I found this solution, based on your ideas @acstll

  const handleClick = (e: MouseEvent, href: string) => {
    e.preventDefault();
    router.push(href);
  };

const navExample = {
      name: "Search",
      id: "Search41",
      href: "#search",
      onClick: (e: MouseEvent) => handleClick(e, "#search"),
      icon: "action-search",
    };

I will close #361 and link this post.

from scale.

acstll avatar acstll commented on May 25, 2024

Hi @christopherGdynia, thanks for your question.

I'm assuming from #361 that you're using Next.js, right?

The links inside the Scale header are plain <a> tags, so they won't directly work with client-side routing depending on the framework you're using (some work, some don't).

There is a way to work around this, by providing an onClick prop in the mainNavigation data and handling the routing programmatically using the useRouter hook from Next.js:

Something like this should work (haven't tested it myself):

import { useRouter } from 'next/router'

function NavigationExample({ children, href }) {
  const router = useRouter()

  const handleClick = (e) => {
    e.preventDefault()
    router.push(href)
  }
  const mainNav = [
    { name: "Home", id: "home", href: "/", onClick: handleClick },
    { name: "About", id: "about", href: "/about", onClick: handleClick },
  ]

  return (
    <ScaleAppShell mainNavigation={mainNav}>
      {/* ... */}
    </ScaleAppShell>
  )
}

Would you be able to try this out?

from scale.

nowseemee avatar nowseemee commented on May 25, 2024

OK, fix is released: 3.0.0-beta.11. Thanks again for raising this issue!

from scale.

acstll avatar acstll commented on May 25, 2024

Amazing, glad to hear.

from scale.

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.