<commit_before>'use strict';

import activate from '../utils/activate';

module.exports = (items, target, dir) => {
  const isNext = dir === 'next';
  const currentIdx = items.indexOf(target);
  let adjacent = items[isNext ? currentIdx + 1 : currentIdx - 1];
  // circularity
  if (!adjacent) {
    adjacent = items[isNext ? 0 : items.length - 1];
  }

  activate(target, adjacent);
};
<commit_msg>fixes #103 dropdown down/up arrows go the correct way (#104)<commit_after>'use strict';

import activate from '../utils/activate';

module.exports = (items, target, dir) => {
  const isNext = dir === 'next' || dir === 'down';
  const currentIdx = items.indexOf(target);
  let adjacent = items[isNext ? currentIdx + 1 : currentIdx - 1];
  // circularity
  if (!adjacent) {
    adjacent = items[isNext ? 0 : items.length - 1];
  }

  activate(target, adjacent);
};

{'fraction_non_alphanumeric': 0.1602787456445993, 'fraction_numerical': 0.016260162601626018, 'mean_word_length': 3.6594594594594594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '505691', 'n_tokens_mistral': 285, 'n_tokens_neox': 268, 'n_words': 79}