-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add Unique IDs to Comment Forms #9062
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9062 +/- ##
=======================================
Coverage ? 82.15%
=======================================
Files ? 100
Lines ? 5936
Branches ? 0
=======================================
Hits ? 4877
Misses ? 1059
Partials ? 0 |
const textArea = 'c'+id+'text'; | ||
const preview = 'c'+id+'preview'; | ||
$E.setState(textArea, preview); | ||
} | ||
|
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.
The changes in this file are mostly due to slightly fixing the indentation.
# used in views/comments/_form.html.erb | ||
def get_textarea_id(location, reply_to) | ||
case location | ||
when :main |
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.
deleting this function, it was unnecessary.
<div class="comment-form-wrapper"> | ||
<div class="card card-body bg-light"> | ||
<form method="post" id="c<%= comment.id %>edit" style="display:none;" class="well" <% if comment.is_a?Answer %> action= "/answers/update/<%= comment.id %>" <% else %> action="/comment/update/<%= comment.id %>" <% end %>> | ||
<div class="card card-body bg-light comment-form-wrapper"> |
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.
I collapsed <div class="card card-body bg-light">
and <div class="comment-form-wrapper">
into one <div>
. I know there's a lot of <div>
spam in the views built up over the years, trying to do my part in reducing it.
I checked the CSS by both viewing locally and hunting through the stylesheets, and this doesn't seem to create any new issues.
@@ -17,7 +17,7 @@ | |||
</div> | |||
</div> | |||
|
|||
<div class="well" id="preview-main" style="display:none;"> </div> | |||
<div class="well" id="comment-preview-main" style="display:none;"> </div> | |||
|
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.
I know this is kind of weird on the wiki editor to have this ID be #comment-preview-main, but I have a master plan for this and will take care of it in the next few PRs.
Basically with an OOP refactor of editor.js
, it will be possible to $E.initialize({default main editor form ID})
.
Code Climate has analyzed commit 698c8cf and detected 0 issues on this pull request. View more on Code Climate. |
Okay, I kept trying to add more to this PR, but I've decided to stop here for now. @jywarren This one is ready to merge! Just to summarize the changes I made in this PR:
I'm basically just trying to get everything organized so that I still need to add unique IDs to
But I will do that in a separate PR! |
This looks great. Is it worth adding some extra CSS assertions to enforce the assumption of:
That way it's actually written somewhere and the convention is documented and protected? CSS assertions are so cheap anyways... |
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.
@jywarren Thanks! I didn't know it was possible to hide whitespace changes. And I'll look into CSS assertions. |
yeah i thought it might be useful to know - it's a lifesaver when reviewing! Thank you!! |
* delete get_textarea_id method publiclab#9004 * change #c23edit selector to #comment-form-edit-23 publiclab#9004 * assign unique IDs to comment forms publiclab#9004 * change selectors from #c1edit to #comment-form-edit-1 publiclab#9004 * change preview IDs from #preview1 to #comment-preview-1 publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004
* delete get_textarea_id method publiclab#9004 * change #c23edit selector to #comment-form-edit-23 publiclab#9004 * assign unique IDs to comment forms publiclab#9004 * change selectors from #c1edit to #comment-form-edit-1 publiclab#9004 * change preview IDs from #preview1 to #comment-preview-1 publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004
* delete get_textarea_id method publiclab#9004 * change #c23edit selector to #comment-form-edit-23 publiclab#9004 * assign unique IDs to comment forms publiclab#9004 * change selectors from #c1edit to #comment-form-edit-1 publiclab#9004 * change preview IDs from #preview1 to #comment-preview-1 publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004
* delete get_textarea_id method publiclab#9004 * change #c23edit selector to #comment-form-edit-23 publiclab#9004 * assign unique IDs to comment forms publiclab#9004 * change selectors from #c1edit to #comment-form-edit-1 publiclab#9004 * change preview IDs from #preview1 to #comment-preview-1 publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004 * change main preview selector to #comment-preview-main from #preview-main publiclab#9004
Related to #9004 (Object-Oriented Refactor of Comment Editor)
See this comment for more context: #9004 (comment)
(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)