File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ function Base.getindex(component::DashBase.Component, id::AbstractString)
48
48
component. id == id && return component
49
49
hasproperty (component, :children ) || return nothing
50
50
cc = component. children
51
- cc isa Union{VecChildTypes, DashBase. Component} ? cc[id] : nothing
51
+ cc isa Union{VecChildTypes, DashBase. Component, Vector{Any} } ? cc[id] : nothing
52
52
end
53
53
function Base. getindex (children:: VecChildTypes , id:: AbstractString )
54
54
for element in children
@@ -57,6 +57,14 @@ function Base.getindex(children::VecChildTypes, id::AbstractString)
57
57
el != = nothing && return el
58
58
end
59
59
end
60
+ function Base. getindex (children:: AbstractVector , id:: AbstractString )
61
+ for element in children
62
+ hasproperty (element, :id ) || continue
63
+ element. id == id && return element
64
+ el = element[id]
65
+ el != = nothing && return el
66
+ end
67
+ end
60
68
61
69
# only name, index_string and layout are available to set
62
70
function Base. setproperty! (app:: DashApp , property:: Symbol , value)
Original file line number Diff line number Diff line change 200
200
end
201
201
@test_throws ErrorException make_handler (app)
202
202
end
203
+
204
+ @testset " Index by id" begin
205
+ app = dash ()
206
+ app. layout = html_div () do
207
+ dcc_input (id = " my-id" , value= " initial value" , type = " text" ),
208
+ html_div (id = " my-div" , children = [
209
+ html_div (),
210
+ " string" ,
211
+ html_div (id = " target" )
212
+ ]),
213
+ html_div (id = " my-div2" )
214
+ end
215
+ @test app[" target" ]. id == " target"
216
+ end
You can’t perform that action at this time.
0 commit comments