#10841 closed defect (fixed)
Less broad CSS rules for styling ticket #properties table
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Milestone: | 1.1.4 |
Component: | rendering | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: |
On the ticket page, the CSS selectors descending from the |
||
Internal Changes: |
Description
I've set up a Trac site that loads a Javascript WYSIWYG editor to edit the ticket description field. The WYSIWYG editor creates a <table>
to present a toolbar to the user.
Trac's ticket.css
contains rules for #properties table
which make the layout of this toolbar table look wrong, because it's a <table>
that's a descendent of the <fieldset id="properties">
. So, in order to make the WYSIWYG toolbar display properly, I need to track down all the #properties table
rules and suppress them with a more specific CSS selector in my own stylesheet.
However, Trac's CSS rule is unnecessarily broad. The only table that the CSS is trying to style is a direct child of the properties fieldset, so using selectors like #properties > table
instead of #properties table
would have the same effect without accidentally styling other tables that might be inserted within the #properties node. I believe the CSS child selector has been supported in all browsers for a while now (IE7+).
Attachments (3)
Change History (20)
by , 12 years ago
Attachment: | ticket_css_propertiestable.diff added |
---|
by , 12 years ago
Attachment: | ticket_css_propertiestable_without_child_selector.diff added |
---|
comment:1 by , 12 years ago
by , 12 years ago
Attachment: | ticket_css_propertiestable_multiple_child_selectors.diff added |
---|
Use multiple child selectors in each rule (table > tbody > tr etc)
comment:2 by , 12 years ago
Actually neither of my first two patches is sufficient, because of course the inner table's <th>
s and <td>
s are still caught by the rule. attachment:ticket_css_propertiestable_multiple_child_selectors.diff fixes this by using a lot of child selectors (e.g. #properties > table > tbody > tr > th
) which makes the application of the rules sufficiently specific.
comment:3 by , 12 years ago
I didn't look at the specifics of the problem yet, but just seeing your latest patch, I think you should aim for simple and efficient CSS by adding whatever is required in terms of IDs or classes (trac-
prefix), rather than trying to cope with the existing structure.
comment:4 by , 12 years ago
Milestone: | → undecided |
---|
All the tickets for {20} from last year have probably been seen multiple times by now, yet are still to be triaged…
comment:5 by , 10 years ago
I took the suggestions from this ticket and prepared the changes in log:rjollos.git:t10841. Ethan, does it solve the issue you were encountering?
comment:7 by , 10 years ago
Milestone: | undecided → 1.0.4 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:8 by , 10 years ago
Milestone: | 1.0.4 → 1.0.5 |
---|
comment:9 by , 10 years ago
Tentative plan is to just apply attachment:ticket_css_propertiestable_multiple_child_selectors.diff, since it's similar to the change in [13662] and will get the job done for now. However, I haven't fully tested that patch yet.
comment:11 by , 10 years ago
API Changes: | modified (diff) |
---|
Proposed changes in log:rjollos.git:t10841.2.
comment:12 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Committed to trunk in [13754].
comment:13 by , 10 years ago
API Changes: | modified (diff) |
---|
comment:14 by , 10 years ago
I noticed a similar issue in trunk. Wiki table in ticket comment in auto preview is rendered as width: 100%
. Wiki table usually is rendered as width: auto
.
follow-up: 16 comment:15 by , 10 years ago
That might be a regression in [13211]. This patch seems to fix the issue.
-
trac/htdocs/css/ticket.css
diff --git a/trac/htdocs/css/ticket.css b/trac/htdocs/css/ticket.css index d442945..1fd8660 100644
a b form .field fieldset { margin-left: 1px; margin-right: 1px 204 204 label[for=comment] { float: right } 205 205 206 206 #propertyform { margin-bottom: 2em; } 207 #propertyform table {207 #propertyform table.trac-properties { 208 208 border-spacing: 0; 209 209 table-layout: fixed; 210 210 width: 100%; 211 211 } 212 #propertyform table td input[type="text"],213 #propertyform table td textarea {212 #propertyform table.trac-properties td input[type="text"], 213 #propertyform table.trac-properties td textarea { 214 214 -moz-box-sizing: border-box; 215 215 box-sizing: border-box; 216 216 width: 100%; -
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht index 98bd234..76c5f2f 100644
a b ${value}</textarea> 327 327 <!--! Comment field --> 328 328 <fieldset> 329 329 <div py:if="authname == 'anonymous'" class="author"> 330 <table >330 <table class="trac-properties"> 331 331 <tr> 332 332 <th> 333 333 <label for="author">Your email or username:</label><br />
If using the CSS child selector is problematic, the same effect could be achieved by adding a class or ID to the relevant table to make the selector more specific. I'm not sure which approach is considered better, so I've attached two patches.