File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -71,10 +71,10 @@ def add_hook(
71
71
return
72
72
hks = self ._ns .get (hook , [])
73
73
74
- p = 0
74
+ p = priority or 0
75
75
if not priority and len (hks ):
76
- priority_max = max (h .priority for h in hks )
77
- p = priority_max - 1
76
+ priority_min = min (h .priority for h in hks )
77
+ p = priority_min - 1
78
78
79
79
hks .append (_Hook (func , priority = p , data = data ))
80
80
self ._ns [hook ] = sorted (hks , reverse = True , key = lambda h : h .priority )
Original file line number Diff line number Diff line change @@ -114,24 +114,26 @@ def hook2(layout):
114
114
layout .children .append (html .Div ("second" ))
115
115
return layout
116
116
117
+ # This appears after the layout
118
+ @hooks .layout (priority = 12 )
119
+ def hook4 (layout ):
120
+ layout .children .append (html .Div ("Prime" ))
121
+ return layout
122
+
123
+ # Should still be last after setting a new max.
117
124
@hooks .layout ()
118
125
def hook3 (layout ):
119
126
layout .children .append (html .Div ("third" ))
120
127
return layout
121
128
122
- @hooks .layout (priority = 6 )
123
- def hook4 (layout ):
124
- layout .children .insert (0 , html .Div ("Prime" ))
125
- return layout
126
-
127
129
app = Dash ()
128
130
129
131
app .layout = html .Div ([html .Div ("layout" )], id = "body" )
130
132
131
133
dash_duo .start_server (app )
132
134
dash_duo .wait_for_text_to_equal ("#final-wrapper > div:first-child" , "final" )
133
- dash_duo .wait_for_text_to_equal ("#body > div:first-child" , "Prime " )
134
- dash_duo .wait_for_text_to_equal ("#body > div:nth-child(2)" , "layout " )
135
+ dash_duo .wait_for_text_to_equal ("#body > div:first-child" , "layout " )
136
+ dash_duo .wait_for_text_to_equal ("#body > div:nth-child(2)" , "Prime " )
135
137
dash_duo .wait_for_text_to_equal ("#body > div:nth-child(3)" , "first" )
136
138
dash_duo .wait_for_text_to_equal ("#body > div:nth-child(4)" , "second" )
137
139
dash_duo .wait_for_text_to_equal ("#body > div:nth-child(5)" , "third" )
You can’t perform that action at this time.
0 commit comments