Fix the bug regarding selected nodes when adding nodes.