First off, great module! Thanks for your hard work!

Sometimes descriptions have multiple lines. They should be displayed as such.

https://git.drupalcode.org/project/formtips/blob/8.x-1.x/css/formtips.cs...

.formtips-processed {
  /* ... */
  white-space: pre-line;
}

https://git.drupalcode.org/project/formtips/blob/8.x-1.x/js/formtips.js#L22

$.trim() or even "".trim() doesn't augment the string being checked. So you must actually set the text or html after trimming if you want to avoid leading/trailing whitespace in the tooltip. Maybe do something like this...

// figured you're already looping with filter, no need to do these augmentations outside of the filter callback.
// but you certainly could...
$descriptions = $descriptions.filter(function () {
  const $el = $(this);
  const trimmed = $.trim($el.text());
        
  $el.text(trimmed);

  return trimmed !== '';
});

Comments

jklmnop created an issue. See original summary.

joelpittet’s picture

Priority: Minor » Normal

That sounds like a promising idea! I've never heard of "pre-line" Is there an example of this somewhere in core that I could test?

joelpittet’s picture

Feel free to submit a patch with the changes, though I've not got es6 stuff setup on this module yet.