ocadotechnology/hexagonjs

AutocompletePicker: `useCache: false` still uses the cache

Closed this issue · 0 comments

Context

When setting up an autocomplete with an external matcher and useCache: false the picker still shows values that were removed from the results that it has retrieved from the cache for the '' search instead of getting values from the endpoint again

Expected Behavior

The autocomplete picker should always get results from the endpoint

Actual Behavior

The autocomplete picker retrieves results from the cache

Possible Fix

Passing the useCache option through to the AutocompleteFeed should resolve the problem

Workaround

Call AutocompletePicker.clearCache() method when removing items from the array in this case would resolve the issue

Steps to Reproduce

let itemsArr = [
  'a',
  'b',
  'c'
]

function items (term, callback) {
  callback(itemsArr.filter((item) => item.indexOf(term) > -1))
}

function removeItem() {
  itemsArr.pop()
}

const acp = hx.div()

new hx.AutocompletePicker(acp, items, {
  matchType: 'external',
  useCache: false
})

const removeBtn = hx.button().text('Remove Item')
  .on('click', removeItem)

hx.select('body').clear()
  .add(acp)
  .add(removeBtn)
  1. Open picker
  2. Click 'Remove Item' button
  3. Open picker again
  4. c is still shown in the list despite being removed from the array
  5. Confirm removal by searching for c

Your Environment

  • Hexagon Version: 1.10.0