Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trix horizontal rule disappears in edit view #2627

Open
sedubois opened this issue Mar 22, 2024 · 12 comments
Open

Trix horizontal rule disappears in edit view #2627

sedubois opened this issue Mar 22, 2024 · 12 comments
Assignees
Labels
Bug Something isn't working Stale exempt

Comments

@sedubois
Copy link
Contributor

sedubois commented Mar 22, 2024

Describe the bug

Trix horizontal rule disappears in edit view.

Steps to Reproduce

  1. Use code from this Gist
  2. Go to article edit view; click on the horizontal rule button in Trix toolbar, this inserts an hr as intended
  3. Click Save, this renders the article show view where the hr is also rendered as intended. The raw value stored in DB is <div><action-text-attachment content-type="vnd.rubyonrails.horizontal-rule.html"></action-text-attachment></div> as intended
  4. click Edit: the hr disappears

Expected behavior & Actual behavior

The hr should be visible on the edit view and should stay persisted to the DB when saving again.

Models and resource files

See gist link above

System configuration

Avo version: 3.5.4

Rails version: 7.0.8.1

Ruby version: 3.3.0

License type: Community

Are you using Avo monkey patches, overriding views or view components?
No

Screenshots or screen recordings

Edit (first pass) - works OK:
Screenshot 2024-03-22 at 09 08 00

Show - works OK:
Screenshot 2024-03-22 at 09 08 12

Edit (second pass) - KO (hr disappears):
Screenshot 2024-03-22 at 09 08 36

Additional context

Trix support for horizontal rule was added as documented in this issue. This system works fine in our legacy Administrate dashboards and the hr renders fine in our front-end. The only issue is when re-editing the resource in Avo.

Impact

Med/high: this prevents us from going live with the Avo dashboards because editing our articles will result in the horizontal rules to disappear.

Urgency

Medium

@adrianthedev
Copy link
Collaborator

@sedubois, a reproduction repo would be a bit more helpful to us to run quickly.
Thank you!

@sedubois
Copy link
Contributor Author

sedubois commented Mar 24, 2024

@adrianthedev see reproduction here:
https://github.com/sedubois/avo-trix-demo

First, in the main app: I could create an article at http://localhost:5000/articles. I could insert a horizontal rule, it showed up fine. It also rendered fine when re-editing the article.

Then I wanted to start configuring things on the Avo side, but I got an error Missing partial avo/action_text/contents/_content with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}. when visiting http://localhost:5000/avo/resources/articles/1.

🐛 This looks like a bug in Avo? As a workaround, I created the view (copied from the actiontext gem: app/views/action_text/contents/_content.html.erb).

🐛 Then the Avo index and show views can render the article. For the edit view however, I had to manually change the body field type from :text to :trix. This also looks like a bug in Avo?

At this point I then added the custom Trix config so that the toolbar buttons showed up fine.

Then you can observe the issue described here: the horizontal rule, which shows up fine in the editor of the main app (at http://localhost:5000/articles/1/edit) does not show up in the Avo editor (at http://localhost:5000/avo/resources/articles/1/edit).

@sedubois
Copy link
Contributor Author

@Paul-Bob as you are working on a Trix PR, FYI there is this issue too, don't know if related

@Paul-Bob
Copy link
Contributor

@sedubois I wasn’t able to reproduce it:

Screen.Recording.2024-03-27.at.11.59.17.mov

@sedubois
Copy link
Contributor Author

Sorry Paul it's because the Avo Trix customization was commented out when applying the changes you asked in the other issue. So the HR button was not available any more in the Avo Trix toolbar.

You can re-test as follows:

  1. Check out this commit: sedubois/avo-debug@5ae2017
  2. Go to Avo article edit view; click on the horizontal rule button in Trix toolbar, this inserts an hr as intended
  3. Click Save, this renders the article show view where the hr is also rendered as intended. The raw value stored in DB is
    as intended
  4. Go to Edit: the hr disappears

Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Apr 14, 2024
@adrianthedev
Copy link
Collaborator

Let's try to fix this as well if it's fixable without any hacks.

Copy link
Contributor

github-actions bot commented May 1, 2024

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label May 1, 2024
@Paul-Bob Paul-Bob removed the Stale label May 1, 2024
@sedubois
Copy link
Contributor Author

sedubois commented May 9, 2024

This issue persists in our application after upgrading to Avo 3.7.3: the hr disappears when re-editing then saving the resource.

So again I tried to isolate the issue in a standalone, shareable repo:
https://github.com/sedubois/avo-debug-3/tree/04b242a7b95d86e418b90685ca86a7df287d82f5

But I can't check if the hr button feature works, as the first issue is that I'm probably setting up the customization the wrong way because there are JS errors below when visiting the Avo article index and when trying to save an article after edit. Any idea what might be misconfigured?

Screenshot 2024-05-09 at 18 32 23 Screenshot 2024-05-09 at 18 32 55

@Paul-Bob
Copy link
Contributor

Paul-Bob commented May 9, 2024

I didn't get the chance to look into it @sedubois. Thanks for the reproduction repository that should help!

Copy link
Contributor

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label May 26, 2024
@adrianthedev adrianthedev added Stale exempt Bug Something isn't working and removed Stale labels May 26, 2024
@adrianthedev
Copy link
Collaborator

We spoke about this on so many issues.
Let's keep the discussion about this on this issue alone.

The status is that it's an edge-case that happens only with has_rich_text and we'd need more time to dig into it.
As we have other priorities right now, we can't delegate our time unless it's sponsored by an organization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Stale exempt
Projects
Status: Next up
Development

No branches or pull requests

3 participants