From b7843da963e2898edbc6cb3ab4fb25d65b3f09f2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 23 Aug 2017 14:45:16 -0700 Subject: [PATCH] Don't expand folded timelines just because users went to any anchor whatsoever Summary: Ref T12970. See PHI43. Currently, the "Show Older Comments" link gets auto-clicked if the user visits **any** anchor. This is not correct. Instead, only auto-click it if the user visits a numeric anchor. This fixes the behavior approximately 98% of the time. See T12970 for a followup on the remaining ambiguous cases. Test Plan: - Viewed a revision with some folded transactions and a "Show Older Comments" link. - Clicked a link to a file in the table of contents, with a hash like `#1234abcd`. - Before: Timeline expanded and I ended up somewhere bad. - After: Timeline no longer expanded. - Manually changed hash to `#1234` (purely numeric), saw timeline expand. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12970 Differential Revision: https://secure.phabricator.com/D18458 --- .../transactions/behavior-show-older-transactions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webroot/rsrc/js/application/transactions/behavior-show-older-transactions.js b/webroot/rsrc/js/application/transactions/behavior-show-older-transactions.js index ab4bf768d8..28754ee3a2 100644 --- a/webroot/rsrc/js/application/transactions/behavior-show-older-transactions.js +++ b/webroot/rsrc/js/application/transactions/behavior-show-older-transactions.js @@ -17,6 +17,13 @@ JX.behavior('phabricator-show-older-transactions', function(config) { if (!hash) { return false; } + + // If the hash isn't purely numeric, ignore it. Comments always have + // numeric hashes. See PHI43 and T12970. + if (!hash.match(/^\d+$/)) { + return false; + } + var id = 'anchor-'+hash; try { JX.$(id);