0

I'm working on a rails app that is using ActionText and trix for rich text content.

I noticed that when I add multiple hyperlinks to an instance of trix, the first one works as expected, the others get prepended to the content that is already there in the box. In this screenshot, for instance I added the hyperlink to "implement" and that worked, and then I added it to "strategies" but the hyperlink got added at the beginning of the content.

enter image description here

I haven't added any custom logic to trix other than allowing for embedding media content. Any idea of why might this be happening? I also tried to remove the media content logic but the issue kept happening.

Any idea as to why this may be happening?

EDIT 1 - Code snippets + additional context

In my section.rb file I added a rich_text field

  class Section < ApplicationRecord
    has_rich_text :content

In the view

<div class="nested-fields bg-gray-100 p-5">
  <div class="flex justify-between items-center mb-10">
    <h6 class="text-sm"> Content </h6>
    <button class="bg-red-400 text-sm text-white p-1 rounded cursor-pointer" data-action="nested-form#remove_association">
      <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
      </svg>
    </button>
  </div>
  <div>
    <%= form.rich_text_area :content %>
  </div>
</div>

It's worth mentioning that this is not happening application-wide. On the same page I have another instance of actiontext that is working as expected.

class Lesson < ApplicationRecord
  has_rich_text :prep_overview
<%= form_with model: [:madmin, record], url: resource.show_path(record), data: { 'tabs-target': 'form' }, class: 'flex flex-col space-y-6' do |f| %>
    <%= f.rich_text_area :prep_overview %>

Another thing I noticed is that the issue seems to be broader than just hyperlinks not being added where they should. I've also noticed that once I add the first hyperlink I'm basically unable to add other text formatting such as bullet points.

ilrock
  • 573
  • 8
  • 24

1 Answers1

0

@ilrock

can you include some code snippets for us to help you debug and hopefully fix the concern/issue you're into?

in case it's not possible, you may refer to Rails Guides on ActionText

hope it helps!

marLox
  • 11
  • 2
  • Sorry, my bad. I added the snippet of where this is happening + some more context that I gather while investigating – ilrock Feb 03 '23 at 05:11