The function RadioactivityEmitter::view() only returns parent::view() if the energy value should be displayed, to prevent rendering an empty field.
But with this approach, RadioactivityEmitter::viewElements() doesn't get executed if you choose the 'No value - only emit' formatter display, because ::view() calls ::viewElements(). This means no JS (triggers.js) will be attached to the field and page visits won't be emitted.
I think the solution is to remove the RadioactivityEmitter::view() function and let Drupal use its FormatterBase::view() instead. This way, no #markup will be returned, but the #attached JS will.
Comment | File | Size | Author |
---|---|---|---|
#4 | radioactivity-no-emits-2846378-4.patch | 1.03 KB | Sutharsan |
Comments
Comment #2
Sutharsan CreditAttribution: Sutharsan commentedI don't think this is an undesired behavior and needs to be fixed. If we remove the field formatter than there is no way to (temporary) prevent emitting the energy. We should address this behavior in the documentation.
Changing the priority to Normal. See https://www.drupal.org/node/45111 for a priority description.
Comment #3
jonnyeom CreditAttribution: jonnyeom as a volunteer commentedPerhaps I am not understanding this issue correctly. Does this mean that at the moment, if the radioactivity field to the 'No value - only emit' formatter display, the functionality of this module is basically not loaded onto any of the pages?
Comment #4
Sutharsan CreditAttribution: Sutharsan commentedI was under the strong impression that 'No value - only emit' just works as advertised. But it does not emit :(
This patch fixes that.
Comment #6
Sutharsan CreditAttribution: Sutharsan commentedThis bugfix is worth a new release. But before that time, I'd like to hear from @all if this fixes the problem at your end too.
Comment #7
jonnyeom CreditAttribution: jonnyeom as a volunteer commentedJust tested with the updated version. The fix is working great. Thanks!
Comment #8
mauritsl CreditAttribution: mauritsl commentedI can confirm that energy is not emitted with when field is not displayed, and that this patch will fix that issue.
A new release would be helpful.