Skip to content

Commit 782fb6a

Browse files
committed
Add tabindex to grid columns which has only plain text to make it tabable
Signed-off-by: Pasam Soujanya <psoujany@in.ibm.com>
1 parent ca3e701 commit 782fb6a

File tree

1 file changed

+17
-0
lines changed
  • src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html

1 file changed

+17
-0
lines changed

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25+
/*
26+
* ===========================================================================
27+
* (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
28+
* ===========================================================================
29+
*/
2530

2631
package jdk.javadoc.internal.doclets.formats.html;
2732

@@ -33,6 +38,7 @@
3338
import java.util.List;
3439
import java.util.Set;
3540
import java.util.function.Predicate;
41+
import java.util.regex.Pattern;
3642

3743
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyles;
3844
import jdk.javadoc.internal.html.Content;
@@ -322,14 +328,25 @@ public void addRow(T item, List<Content> contents) {
322328
}
323329
}
324330
int colIndex = 0;
331+
String regex = "<(?:a|area|button|input|object|select|textarea)\\b";
332+
Pattern pattern = Pattern.compile(regex);
325333
for (Content c : contents) {
326334
HtmlStyle cellStyle = columnStyles.get(colIndex);
327335
// Always add content to make sure the cell isn't dropped
328336
var cell = HtmlTree.DIV(cellStyle).addUnchecked(c.isEmpty() ? Text.EMPTY : c);
337+
boolean matchFound = c.isEmpty() || pattern.matcher(c.toString()).find();
329338
cell.addStyle(rowStyle);
339+
if (!matchFound) {
340+
cell.put(HtmlAttr.ROLE, "tablist")
341+
.put(HtmlAttr.TABINDEX, "0");
342+
}
330343

331344
for (String tabClass : tabClasses) {
332345
cell.addStyle(tabClass);
346+
if (!matchFound) {
347+
cell.put(HtmlAttr.ROLE, "tablist")
348+
.put(HtmlAttr.TABINDEX, "0");
349+
}
333350
}
334351
row.add(cell);
335352
colIndex++;

0 commit comments

Comments
 (0)