提交 32b0f7c9 编写于 作者: A Aarni Koskela

Add support for tooltips on dropdown options

上级 b82d4a65
...@@ -119,10 +119,18 @@ var titles = { ...@@ -119,10 +119,18 @@ var titles = {
function updateTooltip(element) { function updateTooltip(element) {
if (element.title) return; // already has a title if (element.title) return; // already has a title
let tooltip = localization[titles[element.textContent]] || titles[element.textContent]; let text = element.textContent;
let tooltip = localization[titles[text]] || titles[text];
if (!tooltip) { if (!tooltip) {
tooltip = localization[titles[element.value]] || titles[element.value]; let value = element.value;
if (value) tooltip = localization[titles[value]] || titles[value];
}
if (!tooltip) {
// Gradio dropdown options have `data-value`.
let dataValue = element.dataset.value;
if (dataValue) tooltip = localization[titles[dataValue]] || titles[dataValue];
} }
if (!tooltip) { if (!tooltip) {
...@@ -170,7 +178,8 @@ onUiUpdate(function(mutationRecords) { ...@@ -170,7 +178,8 @@ onUiUpdate(function(mutationRecords) {
node.tagName === "SPAN" || node.tagName === "SPAN" ||
node.tagName === "BUTTON" || node.tagName === "BUTTON" ||
node.tagName === "P" || node.tagName === "P" ||
node.tagName === "INPUT" node.tagName === "INPUT" ||
(node.tagName === "LI" && node.classList.contains("item")) // Gradio dropdown item
) { ) {
tooltipCheckNodes.add(node); tooltipCheckNodes.add(node);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册