File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 7
7
runs-on : ubuntu-latest
8
8
9
9
steps :
10
- - uses : actions/labeler@v2
10
+ - uses : actions/labeler@v4
11
11
with :
12
12
repo-token : " ${{ secrets.GITHUB_TOKEN }}"
Original file line number Diff line number Diff line change @@ -40,6 +40,28 @@ mutable struct DashApp
40
40
41
41
end
42
42
43
+ const VecChildTypes = Union{NTuple{N, DashBase. Component} where {N}, Vector{<: DashBase.Component }}
44
+
45
+ function Base. getindex (component:: DashBase.Component , id:: AbstractString )
46
+ component. id == id && return component
47
+ hasproperty (component, :children ) || return nothing
48
+ cc = component. children
49
+ return if cc isa Union{VecChildTypes, DashBase. Component}
50
+ cc[id]
51
+ elseif cc isa AbstractVector
52
+ identity .(filter (x-> hasproperty (x, :id ), cc))[id]
53
+ else
54
+ nothing
55
+ end
56
+ end
57
+ function Base. getindex (children:: VecChildTypes , id:: AbstractString )
58
+ for element in children
59
+ element. id == id && return element
60
+ el = element[id]
61
+ el != = nothing && return el
62
+ end
63
+ end
64
+
43
65
# only name, index_string and layout are available to set
44
66
function Base. setproperty! (app:: DashApp , property:: Symbol , value)
45
67
property == :index_string && return set_index_string! (app, 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. layout[" target" ]. id == " target"
216
+ @test app. layout[" ups" ] === nothing
217
+ end
You can’t perform that action at this time.
0 commit comments