GithubHelp home page GithubHelp logo

Comments (2)

antonymilne avatar antonymilne commented on May 8, 2024

Currently this is the expected behaviour, but I think you're right we should change the behaviour.

There's two different things here:

  • when you set Page.path, it's correct that we convert whitespace to - to make a clean valid URL for the page
  • when you set Card.href, remember this can be a link to anything, not just a link inside your app. Hence it's valid to put in e.g. Card.href = "http://www.example.com/something with space" (space is not a valid character in a URL and it should be encoded as %20, but this encoding always happens automatically when you click the link so there's not really any point us doing it I think. Even if we did encode it, we should not convert spaces to - because it would contradict the correct HTML encoding of %20)

The case you give here is a special (but common) case where you use Card.href to refer to a page in the app and hence use a relative link. We handle this as:

href=get_relative_path(self.href) if self.href.startswith("/") else self.href

I think we should change this:

  1. put self.href through the same clean_path transformation that Page.path has in the case that it's a relative path. Hence writing Card.href = "/page page" would then work
  2. even better, make it so that you can just write Card.href = "page page" without the leading / and it would still work. This would mean we need a better check to see if the href is relative or absolute and to add the / back in the case that it's not absolute and it's missing

This way a user will be able to put the page title directly in the Card.href without thinking about it even if it's got weird characters, i.e. this should work:

Page(title = "something weird %*")
Card(href = "something weird %*")

from vizro.

antonymilne avatar antonymilne commented on May 8, 2024

After more thought we should not implement this feature for now. See #348 for explanation.

from vizro.

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.