Skip to content

Commit bbe2290

Browse files
authored
Merge pull request #2605 from plotly/fix/html-autoFocus
Add hardcoded autoFocus to html attributes
2 parents fd50851 + 9f9e4d2 commit bbe2290

File tree

2 files changed

+73
-47
lines changed

2 files changed

+73
-47
lines changed

components/dash-html-components/scripts/data/attributes.json

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"attributes": {
3+
"autoFocus": {
4+
"elements": [
5+
"button",
6+
"input",
7+
"select",
8+
"textarea"
9+
],
10+
"description": "The element should be automatically focused after the page loaded."
11+
},
312
"accept": {
413
"elements": [
514
"form",
@@ -736,18 +745,21 @@
736745
}
737746
},
738747
"elements": {
739-
"form": [
740-
"accept",
741-
"acceptCharset",
742-
"action",
743-
"autoComplete",
744-
"encType",
745-
"method",
748+
"button": [
749+
"autoFocus",
750+
"disabled",
751+
"form",
752+
"formAction",
753+
"formEncType",
754+
"formMethod",
755+
"formNoValidate",
756+
"formTarget",
746757
"name",
747-
"noValidate",
748-
"target"
758+
"type",
759+
"value"
749760
],
750761
"input": [
762+
"autoFocus",
751763
"accept",
752764
"alt",
753765
"autoComplete",
@@ -780,6 +792,43 @@
780792
"value",
781793
"width"
782794
],
795+
"select": [
796+
"autoFocus",
797+
"autoComplete",
798+
"disabled",
799+
"form",
800+
"multiple",
801+
"name",
802+
"required",
803+
"size"
804+
],
805+
"textarea": [
806+
"autoFocus",
807+
"autoComplete",
808+
"cols",
809+
"disabled",
810+
"form",
811+
"inputMode",
812+
"maxLength",
813+
"minLength",
814+
"name",
815+
"placeholder",
816+
"readOnly",
817+
"required",
818+
"rows",
819+
"wrap"
820+
],
821+
"form": [
822+
"accept",
823+
"acceptCharset",
824+
"action",
825+
"autoComplete",
826+
"encType",
827+
"method",
828+
"name",
829+
"noValidate",
830+
"target"
831+
],
783832
"Globalattribute": [
784833
"accessKey",
785834
"className",
@@ -836,30 +885,6 @@
836885
"src",
837886
"type"
838887
],
839-
"select": [
840-
"autoComplete",
841-
"disabled",
842-
"form",
843-
"multiple",
844-
"name",
845-
"required",
846-
"size"
847-
],
848-
"textarea": [
849-
"autoComplete",
850-
"cols",
851-
"disabled",
852-
"form",
853-
"inputMode",
854-
"maxLength",
855-
"minLength",
856-
"name",
857-
"placeholder",
858-
"readOnly",
859-
"required",
860-
"rows",
861-
"wrap"
862-
],
863888
"audio": [
864889
"autoPlay",
865890
"controls",
@@ -942,18 +967,6 @@
942967
"src",
943968
"srcLang"
944969
],
945-
"button": [
946-
"disabled",
947-
"form",
948-
"formAction",
949-
"formEncType",
950-
"formMethod",
951-
"formNoValidate",
952-
"formTarget",
953-
"name",
954-
"type",
955-
"value"
956-
],
957970
"fieldset": [
958971
"disabled",
959972
"form",
@@ -1067,4 +1080,4 @@
10671080
"value"
10681081
]
10691082
}
1070-
}
1083+
}

components/dash-html-components/scripts/extract-attributes.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ const supportedAttributes = ['accept', 'accessKey', 'action', 'allow',
3131
'srcDoc', 'srcLang', 'srcSet', 'start', 'step', 'style', 'summary', 'tabIndex',
3232
'target', 'title', 'type', 'useMap', 'value', 'width', 'wmode', 'wrap'];
3333

34+
35+
const hardcodedAttributes = {
36+
autoFocus: {
37+
elements: [
38+
"button",
39+
"input",
40+
"select",
41+
"textarea"
42+
],
43+
description: "The element should be automatically focused after the page loaded."
44+
}
45+
}
46+
3447
// Create a map of HTML attribute to React prop
3548
// e.g. {"datetime": "dateTime"}
3649
const attributeMap = supportedAttributes.reduce((map, reactAttribute) => {
@@ -58,7 +71,7 @@ function extractAttributes($) {
5871
if($table.length !== 1) {
5972
throw new Error('page structure changed at ' + htmlURL);
6073
}
61-
const attributes = {};
74+
const attributes = hardcodedAttributes;
6275

6376
$table.find('tbody tr').each((i, row) => {
6477
const $children = cheerio(row).find('td');

0 commit comments

Comments
 (0)