<commit_before>(function(Modules) {
  "use strict";

  let normalize = (string) => string.toLowerCase().replace(/ /g,'');

  let filter = ($searchBox, $targets) => () => {

    let query = normalize($searchBox.val());

    $targets.each(function() {

      let content = $('.live-search-relevant', this).text() || $(this).text();

      if ($(this).has(':checked').length) {
        $(this).show();
        return;
      }

      if (query == '') {
        $(this).css('display', '');
        return;
      }

      $(this).toggle(
        normalize(content).indexOf(normalize(query)) > -1
      );

    });

  };


  Modules.LiveSearch = function() {

    this.start = function(component) {

      let $component = $(component);

      let $searchBox = $('input', $component);

      let filterFunc = filter(
        $searchBox,
        $($component.data('targets'))
      );
<commit_msg>Fix sticky with find as you type<commit_after>(function(Modules) {
  "use strict";

  let normalize = (string) => string.toLowerCase().replace(/ /g,'');

  let filter = ($searchBox, $targets) => () => {

    let query = normalize($searchBox.val());

    $targets.each(function() {

      let content = $('.live-search-relevant', this).text() || $(this).text();

      if ($(this).has(':checked').length) {
        $(this).show();
        return;
      }

      if (query == '') {
        $(this).css('display', '');
        return;
      }

      $(this).toggle(
        normalize(content).indexOf(normalize(query)) > -1
      );

    });

    // make sticky JS recalculate its cache of the element's position
    // because live search can change the height document
    if ('stickAtBottomWhenScrolling' in GOVUK) {
      GOVUK.stickAtBottomWhenScrolling.recalculate();
    }

  };


  Modules.LiveSearch = function() {

    this.start = function(component) {

      let $component = $(component);

      let $searchBox = $('input', $component);

      let filterFunc = filter(
        $searchBox,
        $($component.data('targets'))
      );

{'fraction_non_alphanumeric': 0.18574938574938574, 'fraction_numerical': 0.0009828009828009828, 'mean_word_length': 2.4450084602368864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4536659', 'n_tokens_mistral': 639, 'n_tokens_neox': 589, 'n_words': 125}