Skip to content

Add option for tooltips to be created via data attributes - #71

Open
oscgonfer wants to merge 5 commits into
smark-1:mainfrom
oscgonfer:main
Open

Add option for tooltips to be created via data attributes#71
oscgonfer wants to merge 5 commits into
smark-1:mainfrom
oscgonfer:main

Conversation

@oscgonfer

Copy link
Copy Markdown

Hi @smark-1
Thank you for this plugin!

I wanted to submit a PR for an alternative way to populate the terms via data-[...] attributes instead of requests via DRF. The idea is that we can pass term and definition to the tooltip directly.

In addition, this adds a couple of additional settings to be able to limit the word length of the tooltip, and to add a link on the bottom part that brings you to a different page (customizable) with a list of terms. An example of this can be found here:

more4nature-eu/knowledge-platform#64

There are a couple of pending things that I can work on if you like the idea.

@oscgonfer oscgonfer changed the title Add option for terms to be created Add option for terms to be created via data attributes Jul 13, 2026
@oscgonfer oscgonfer changed the title Add option for terms to be created via data attributes Add option for tooltips to be created via data attributes Jul 13, 2026
@smark-1

smark-1 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

@oscgonfer I didn't have a chance to look at this yet but I like the idea. I thought about doing it this way in the first place but I had some performance concerns and wasn't sure how caching would work. Adding it as an opt in feature sounds like a good idea to me.

Can you add some docs and tests for this?
Also does this work with cached pages - will a term definition update invalidate all the pages that use the term? It's a non blocker since this is a non breaking feature but a warning should be added if turning on this feature can result in a stale cache where it would otherwise be valid.

@oscgonfer

Copy link
Copy Markdown
Author

Can you add some docs and tests for this?
Hi @smark-1 thank you for the positive feedback! I can certainly add some docs, although I am not familiar with how to add tests. Do you have any plans to add this on the package? I'd appreciate guidance if you can.

Also does this work with cached pages - will a term definition update invalidate all the pages that use the term? It's a non blocker since this is a non breaking feature but a warning should be added if turning on this feature can result in a stale cache where it would otherwise be valid.
Not sure I understand, but pages store the term in the data attribute. If the term is updated, the page using it would need to be regenerated under the current schema - however, it doesn't break the page. I am not sure how this could be solved, as I am not so familiar with Wagtail plugin development, but I can give it a go if we agree on how it should be done.

One way I see this last bit could be implemented is that (as you point out), when a term is updated and it's being used with this method, the banner should should show a warning indicating that the pages need to be republished. However, if the user has added this term in multiple locations, the banner can become unusable (and I am not sure if we want to do that for the user automatically, as there may be drafts and all sort of other things waiting).

image

Not sure what the best option is though. Maybe you have another idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants