-
-
Notifications
You must be signed in to change notification settings - Fork 293
Fix disabled and readonly on trix field #3939
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
Fix disabled and readonly on trix field #3939
Conversation
Code Climate has analyzed commit 4911fb7 and detected 0 issues on this pull request. View more on Code Climate. |
@Paul-Bob I've laid out an initial approach to fix the Trix field readonly bug However currently the Lmk what you think. Thanks |
I've added tests for this as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zhephyn, you're on fire! Thanks for this contribution.
The approach is on the right track, but I think we can achieve a more elegant execution.
Take a look at how the component_for_view
method works, every field has it, and it essentially returns the component used to render a field based on the current view.
We can override that method within the Trix field file and perform the readonly
/disabled
check there. If the view is a form (view.form?
) and the field is readonly
or disabled
, the method can return the show component instead. This way, we avoid burdening the edit component with duplicative logic from the show component.
Let me know if this makes sense or if you have any questions.
Thanks again, really appreciate your contributions!
@Paul-Bob New changes are up. Kindly take a look whenever its convenient for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you @zhephyn
Description
The Trix field has no straightforward way to render disabled input. To bypass this, the suggested approach was to render the Trix show component within the edit form if either
disabled
orreadonly
is set to true.Show page

Edit page

The body of the event is shown instead of the Trix field editor on the Edit page when
disabled
orreadonly
are set to true like below:Fixes #3888
Checklist: