Fix cli wrong parent item issue when update listing

this commit follows the client context menu code. if you'd like to pick the function into other code base, you can see how to do the work in the second commit of this PR.