Cytoscape and dropdown node selection callback

I am trying to implement a call back function for the concurrent updates of cytoscape selected node style and a dropdown list showing node lables. The idea is that if the selected name from the dropdown changes, then the corresponding node in the network is highlighted by a style, AND, if user click on a node in the network, then the label/name of the node is shown in the dropdown list. I am not sure how we may be able to track whether the callback would be triggered by the dropdown or the node selection in cytoscape

Here is my attempt but only work one way or the other. All suggestions appreciated. Thank you.



    Output("net_cytoscape", "elements"),

    Output("student_name_drop", "value"),



    Input("net_cytoscape", "selectedNodeData"),

    Input("student_name_drop", "value"),



def select_nodes(




# Generate node list

node_list =[



            'id'                    :str(student['Participant-ID']),

            'label'                 :str(student['Full Name']),

            'house'                 :str(student['House']),


        "classes"       : str(student['House']),

        "selectable"    : True,

        "grabbable"     : False,



    for _, student in student_df.iterrows()


udpated_student_name = current_selected_node

if selected_node_data_list is not None:

    if len(selected_node_data_list) > 0:

        node_data = selected_node_data_list[-1]

        udpated_student_name = node_data["label"].title()


    for node in node_list:

        if ' selected_node' in node['classes']:

            node['classes'].replace(' selected_node', '')

        if (node['data']['label']== udpated_student_name) and (not ' selected_node' in node['classes']):

            node['classes'] += ' selected_node'


# Generate edge list




            'source'    : str(edges.Source),

            'target'    : str(edges.Target),


        "classes"   : str(edges.net_name),

        "locked"    : True,


    for _, edges in edge_list_df.iterrows()


element_list = node_list + edge_list

return [element_list, udpated_student_name]