Template talk:Row hover highlight
| This is the talk page for discussing improvements to the Row hover highlight template. |
|
mw-datatable class had white background for data cells
[edit]Guarapiranga. Please have a look at: T284802. I started that task back when mw-datatable was still working. I wrote:
- "class=mw-datatable (usually combined with class=wikitable) is used more and more. It produces a white background color that is preferred by many for statistic tables. Due to the better contrast and readability for many people. Versus the light gray background color of class=wikitable used alone. Plus class=mw-datatable will highlight the row that the cursor hovers over. Making it easier to scan across that row, especially if it is a long row."
Template:Import-blanktable/styles.css duplicated what mw-datatable did when it was working.
See examples: Help:Table#tpl-blanktable – row highlighting via cursor hover. White background
Can you add the white background too? --Timeshifter (talk) 13:35, 8 June 2022 (UTC)
- Guarapiranga. Please try this out. It's what people expect from class=mw-datatable.
- Comparing the CSS:
- Template:Row hover highlight/styles.css
.hover-highlight tr:hover td,
.mw-datatable tr:hover td {background-color: #eaf3ff}
.tpl-blanktable {
background: #fff;
}
.tpl-blanktable tr:hover {
background: #eaf3ff;
}
So the combination would be?:
.hover-highlight tr:hover td,
.mw-datatable {background: #fff;}
.mw-datatable tr:hover td {background-color: #eaf3ff}
- Timeshifter, I followed Jdlrobson's suggestion at T287997 upon Izno's recommendation that it should solely add the hover over effect rather than make any other modifications to the relevant CSS. If you want to see a specific css, you know you can add it to your common.css or skin.css, right? For more than that, you need consensus (which you clearly don't have). — Guarapiranga ☎ 00:39, 19 June 2022 (UTC)
- Jdlrobson gave some CSS that would work for hover. He did not say he was against the white background. And he did not follow Izno's comment. Izno's comment was later in the task thread. And Izno was talking about what should be incorporated into global or common CSS, not a template.
- Krinkle agreed with me, and quoted me, and created a template that incorporated both the hover and the white background. See: Krinkle comment
- Several others in T287997 supported keeping mw-datatable in global CSS as is, and that was with both hover and white background. For example, see Eric0892 comment.
- In global CSS it was liked and used many times in other language wikis too. XanonymusX comment. And Base comment.
- I see a simpler solution, Guarapiranga.
- {{mw-datatable}} should redirect instead to Krinkle's template, Template:Import-blanktable. See redirect page:
- https://en.wikipedia.org/w/index.php?title=Template:Mw-datatable&redirect=no
- As discussed in T287997 Krinkle worked on mw-datatable in 2011. He created the template to duplicate it after mw-datatable no longer worked correctly in global CSS.
- Also, this way we avoid duplication with your template here that currently only does hover highlighting.
- Of course some additional mw-datatable CSS would have to be added to Template:Import-blanktable to allow it to work on all the many old pages using class=mw-datatable that now have {{mw-datatable}} added above the table wikitext by you and others.
- --Timeshifter (talk) 04:13, 19 June 2022 (UTC)
- Timeshifter, I followed Jdlrobson's suggestion at T287997 upon Izno's recommendation that it should solely add the hover over effect rather than make any other modifications to the relevant CSS. If you want to see a specific css, you know you can add it to your common.css or skin.css, right? For more than that, you need consensus (which you clearly don't have). — Guarapiranga ☎ 00:39, 19 June 2022 (UTC)
Guarapiranga. What is the normal naming system for CSS template sandboxes? I don't have a lot of time, but I can try to test this.
It's been a long time since I did CSS sandbox tests for templates. If ever. I don't remember. And I probably used incorrect naming.
Is there a forum just for template help? --Timeshifter (talk) 02:24, 16 June 2022 (UTC)
Merge discussion
[edit]See: Wikipedia:Templates for discussion/Log/2022 June 19#Template:Import-blanktable. --Timeshifter (talk) 22:54, 19 June 2022 (UTC)
White background added per merge discussion close
[edit]Per the merge discussion closing here:
"The result of the discussion was merge to Template:Row hover highlight."
.mw-datatable {background: #fff;}
Added here: Template:Row hover highlight/styles.css
See diff. You can see it right away by saving the page with the table. Even a save without making any changes. This will not show up in the edit history.
I am talking about tables that are using {{mw-datatable}} just above the table, and class=mw-datatable within the table.
I did some more tests here: User:Timeshifter/Sandbox177. I don't see any problems with background colors set for rows, or individual cells. See sections titled: "With Template:mw-datatable and class=mw-datatable"
I am going to wait before adding the CSS for this to have a white background:
{{row hover highlight}}
{| class="wikitable hover-highlight"
|+ Caption text
|-
! Header text !! Header text !! Header text
|-
| Example || Example || Example
|-
| Example || Example || Example
|-
| Example || Example || Example
|}
| Header text | Header text | Header text |
|---|---|---|
| Example | Example | Example |
| Example | Example | Example |
| Example | Example | Example |
Do I just add this?
.hover-highlight {background: #fff;}
Like this?
.hover-highlight tr:hover td,
.hover-highlight {background: #fff;}
.mw-datatable tr:hover td {background-color: #eaf3ff}
.mw-datatable {background: #fff;}
Krinkle's template seems to be doing this more simply (without td):
I compressed the format:
.tpl-blanktable {background: #fff;}
.tpl-blanktable tr:hover {background: #eaf3ff;}
--Timeshifter (talk) 20:13, 7 October 2022 (UTC)
Merging
[edit]I was looking at the pending merger. Currently, we have three classes that add a highlight (#eaf3ff) upon hover, but they all do it slightly differently:
| Name | Template | Adds functionality to header? | Adds white background? |
|---|---|---|---|
mw-datatable |
{{Row hover highlight}} | No | Yes |
hover-highlight |
{{Row hover highlight}} | No | No |
tpl-blanktable |
{{import-blanktable}} | Yes | Yes |
The easiest way to merge the templates would be to support all three classes at Template:Row hover highlight/styles.css. However, I suspect that this merge has not been completed in the past 17 months because that is not the solution anyone wants. I propose we deprecate tpl-blanktable in favor of mw-datatable. The header is already distinguished from the rest of the table, so it does not need to be highlighted. HouseBlastertalk 23:43, 23 December 2023 (UTC)
- HouseBlaster. The header row highlighting is for tables that don't use class=wikitable. Those headers are the same color as the data cells. So row highlighting of the headers would be useful in that case. The CSS for it could be merged into the CSS for {{Row hover highlight}}.
- I believe there are bots that can substitute {{Row hover highlight}} for {{import-blanktable}}. They could also substitute mw-datatable for tpl-blanktable. The bots would have to make around 400 substitutions.--Timeshifter (talk) 00:44, 24 December 2023 (UTC)
- For clarity, you are proposing we deprecate
tpl-blanktable, but add the heading functionality to the other two classes? If so, I would support that proposed solution. HouseBlastertalk 01:51, 24 December 2023 (UTC)- Yes, that is what I propose. But the tpl-blanktable class would have to stay functional until all the class substitutions were done. We can say that it is deprecated now, so that people stop adding it to more tables.
- We could just add the tpl-blanktable class to {{Row hover highlight}} CSS now.
- Then we could redirect {{import-blanktable}} to {{Row hover highlight}}.
- Then we could merge the header functionality to the other 2 classes. Then we could use the bots to substitute the mw-datatable class for tpl-blanktable. --Timeshifter (talk) 02:16, 24 December 2023 (UTC)
- I don't think it would be worthwhile to include
tpl-blanktablein {{row hover highlight}}. Right now, it is easy to tell which pages usetpl-blanktable(and thus which pages need to be fixed): it is just the pages which transclude {{import-blanktable}}. It would also make it easier to usetpl-blanktable, which is counterproductive.I have gone ahead and added the header functionality. HouseBlastertalk 02:33, 24 December 2023 (UTC)- As long as the bots do both substitutions in the same day, then there will not be any serious disruption. But if the 2 substitutions are separated by days, weeks, months, then there is no row highlighting on the ~400 pages during that time.
- I would rather nuke {{import-blanktable}} now by redirecting it. Of course that would mean having to add the tpl-blanktable class now too. But we don't have to tell anybody about it. While waiting for its substitution to occur. --Timeshifter (talk) 02:45, 24 December 2023 (UTC)
- I think it would be easier if we changed both the template and the name of the class in the same edit. HouseBlastertalk 03:04, 24 December 2023 (UTC)
- I don't think it would be worthwhile to include
- For clarity, you are proposing we deprecate
If we redirected the {{import-blanktable}} page, then its info would no longer exist. People wouldn't know about it or its class. So less use. I don't know what you mean about changing the class name. Are you talking about substitution by bot? --Timeshifter (talk) 03:10, 24 December 2023 (UTC)
- I mean edits like this, which change {{import-blanktable}} to {{row hover highlight}} and
tpl-blanktabletomw-datatablein the same edit. HouseBlastertalk 03:13, 24 December 2023 (UTC)- Around 400 times? How long will that take for you? I think there are bots that can do the separate substitutions automatically. Not sure. --Timeshifter (talk) 03:20, 24 December 2023 (UTC)
- An hour and a bit?
HouseBlastertalk 04:21, 24 December 2023 (UTC)
- An hour and a bit?
- Around 400 times? How long will that take for you? I think there are bots that can do the separate substitutions automatically. Not sure. --Timeshifter (talk) 03:20, 24 December 2023 (UTC)
"Template:Import-blanktable" listed at Redirects for discussion
[edit]
The redirect Template:Import-blanktable has been listed at redirects for discussion to determine whether its use and function meets the redirect guidelines. Readers of this page are welcome to comment on this redirect at Wikipedia:Redirects for discussion/Log/2024 March 14 § Template:Import-blanktable until a consensus is reached. HouseBlaster (talk · he/him) 16:09, 14 March 2024 (UTC)
Doesn't work when using sticky headers without wikitable class
[edit]Conversation moved to Template talk:Sticky header#This template stops another from working without the wikitable class to avoid multiple conversations. Jroberson108 (talk) 13:05, 27 October 2024 (UTC)
Color request
[edit]Hi. Could you change the Template styles to the code
.hover-highlight tr:hover td,
.mw-datatable tr:hover td {
background-color: var(--background-color-progressive-subtle, #f1f4fd) !important;
color: var(--color-base, #202122) !important;
}
.mw-datatable {
background-color: var(--background-color-base, #fff);
color: var(--color-base, #202122);
}
please? The differences are: new "td" in lines 1 and 2 and new "!important" in line 3 in 4. For now, the template does not help if some cells have their one background. See Special:Permalink/1310755637 for what I want to achieve. Thank you in advance. IKhitron (talk) 12:50, 11 September 2025 (UTC)
- @IKhitron: Mediawikiwiki:Manual:Coding conventions/CSS#!important says we should avoid using
!important. Second, I would think if a cell has a background color, it's done to convey information, hopefully according to accessibility guidelines per Wikipedia:Manual of Style/Accessibility#Color. So removing that information might be undesirable for others, even though it's only during hover or long tap. Jroberson108 (talk) 16:22, 11 September 2025 (UTC)- A pity. Because there should be a way to show to user the full line. Will it help if I'll try to find a way to do this without changing original background color, and with or without important, we'll see? IKhitron (talk) 16:28, 11 September 2025 (UTC)
- @IKhitron: I'm not saying it can't be done. I'm only giving my thoughts on how it would affect background-color if conveyed as information. It would be minimally affected since it is only during hover or a long tap on mobile, but I think a few others should chime in on any potential caveats. One example of heavy reliance on background-color might be Wikipedia:Reliable sources/Perennial sources#Sources, even though that particular example doesn't use this template. There are these potentials too: Template:Table cell templates. There may be others. To me, it seems like something you don't want to blanketly do. Jroberson108 (talk) 16:47, 11 September 2025 (UTC)
- IMHO, removing all the background colors in the table I linked above is exactly what I need, and I pretty much wrote most of this table. If you don't want this effect in another table - don't use the suggested new style there. IKhitron (talk) 16:50, 11 September 2025 (UTC)
- I think now I wasn't clear enough before. I mean, if changing the current style is a problem, we can easily add a new style with different behavior, there can't be more than one in the styles files. IKhitron (talk) 06:47, 12 September 2025 (UTC)
- @IKhitron: New styles can still be used to override information conveyed through background-color. For me, that intentional information makes it easier to read more than the hover color overriding it. My opinion is don't remove information meant to make it easier to read. Also, unless there is a really good reason, avoid making it harder to override with
!importantper guidelines. - If it is simply a personal preference, you could easily override this template's styles in your user common.css styles. Jroberson108 (talk) 12:08, 12 September 2025 (UTC)
- I see. I believe the hover highlight not exists to read, but to find the right line, and while found, it is removed and all data is shown, IKhitron (talk) 13:01, 13 September 2025 (UTC)
- @IKhitron: New styles can still be used to override information conveyed through background-color. For me, that intentional information makes it easier to read more than the hover color overriding it. My opinion is don't remove information meant to make it easier to read. Also, unless there is a really good reason, avoid making it harder to override with
- I think now I wasn't clear enough before. I mean, if changing the current style is a problem, we can easily add a new style with different behavior, there can't be more than one in the styles files. IKhitron (talk) 06:47, 12 September 2025 (UTC)
- IMHO, removing all the background colors in the table I linked above is exactly what I need, and I pretty much wrote most of this table. If you don't want this effect in another table - don't use the suggested new style there. IKhitron (talk) 16:50, 11 September 2025 (UTC)
- @IKhitron: I'm not saying it can't be done. I'm only giving my thoughts on how it would affect background-color if conveyed as information. It would be minimally affected since it is only during hover or a long tap on mobile, but I think a few others should chime in on any potential caveats. One example of heavy reliance on background-color might be Wikipedia:Reliable sources/Perennial sources#Sources, even though that particular example doesn't use this template. There are these potentials too: Template:Table cell templates. There may be others. To me, it seems like something you don't want to blanketly do. Jroberson108 (talk) 16:47, 11 September 2025 (UTC)
- A pity. Because there should be a way to show to user the full line. Will it help if I'll try to find a way to do this without changing original background color, and with or without important, we'll see? IKhitron (talk) 16:28, 11 September 2025 (UTC)
Colors in tables are a complicated subject: