Problem/Motivation
I just want to say kudos to the developers for designing this module to apply a 10px offset default when no modifiers are passed. popperjs default offset is 0, way too close! I expect most of time it's overridden, at least it is in examples.
I've been playing around with popperJS on its own and noticed the default popperjs offset is 0, far too close. Plenty of ways to adjust that, and did that in a sandbox just fine. After I installed this module, I noticed the offset was also set to 0. As recommended in the documentation, using modifiers for popperjs I bumped it to 10px.
{% set options = {"content": item.tooltip_content, "placement": "auto", "modifiers": [{"name": "offset", "options": {"offset": [0, 10]}}]} %}
I figure maybe I should just set that default in tooltip.js, so I don't need to maintain a bunch of nested objects, arrays in twig. When in tooltip.js, instanciateTooltip() is already built to set a default of 10. That's what I was going to set it to anyways, but then why wasn't it applying when I wasn't using a modifier?
Steps to reproduce
Use the twig examples in the documentation, don't use 'modifiers' and the tooltip is right up against the triggering element. console.log() the incoming attr.modifiers, etc.
Proposed resolution
When we check whether an offset modifier is passed, use 'some' instead of 'filter' so it properly detects the fallback empty array when attr.modifiers is undefined so it can push the offset.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3516780-default-offset.patch | 726 bytes | spelcheck |
Issue fork tooltip-3516780
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
spelcheck commentedLooks like patches are no longer recommended- will create a MR, but here's what I'm using now.