Fix getDirectionFromSelection to work with table selections

Change-Id: Ie5c46e4eb0fc40982a47adb7ddb47a949d9de411
Merge "Fix getDirectionFromSelection to work with table selections"