Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The title attribute is being ignored #1799

Open
dahlalex opened this issue Jul 18, 2023 · 2 comments
Open

The title attribute is being ignored #1799

dahlalex opened this issue Jul 18, 2023 · 2 comments
Labels
PR accepted Anyone can write a PR for this issue

Comments

@dahlalex
Copy link
Contributor

The layer attributes seem to have a bug that is causing the title to be ignored when url and urlPrefix are used.

bug5

@Grammostola
Copy link
Contributor

Verified. This example in the documentation https://github.com/origo-map/origo-documentation/blob/master/content/layers.md#attributes doesn't work as expected. Well, not as I expect (title is ignored).

This appears to be due to around https://github.com/origo-map/origo/blob/master/src/getattributes.js#L104

Use a common title for all links. If no splitter only one link is assumed and title is used as link text instead.

but the name is used as link text, title appears ignored when url, unless a splitter is employed.

If that part is redone by removing the check for a splitter prop, to look like so:

    // Use a common title for all links. If no splitter only one link is assumed and title is used as link text instead.
    if (attribute.title) {
      val = `<b>${attribute.title}</b>`;
    }

it seems to work as I envision it. But my vision might be milky, what say colleagues who may be more knowledgeable regarding the intentions behind the current workings?

@steff-o
Copy link
Contributor

steff-o commented Aug 18, 2023

Not sure what the original intent was, but in #1372 I tried to keep the original behavior while adding the linktext. When I did that I broke out a helper function to avoid implementing the Url creation twice. Before my changes the title option seems to be honored if "name" option is also used, but not when "name" option was missing.

But #1775 changed everything as it tries the "url" option before the "name" option which runs different code and stumbles on the code that @Grammostola points out.

So much for history, but how should it work?

I think that:

  1. "title" should be reserved for attribute title, not to be used as linktext. Right now it can become the linktext if "name" is missing,
  2. getContent should be cleaned up to avoid duplicate implementation which caused this confusion
  3. Not sure what "name" in combination with "url" should mean. Right now it becomes the linktext.
  4. The "linktext" option should be supported even without splitter. It is more obvious than "name"
  5. The "html" option can be used as linktext. This is not documented.

@jokd jokd added the PR accepted Anyone can write a PR for this issue label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR accepted Anyone can write a PR for this issue
Projects
None yet
Development

No branches or pull requests

4 participants