stable

Clone or download

Read-only

Have a destroy() function to remove events listeners on document

part of: story #16645 have searchable (multi) select boxes with (static binding, no dependencies) We need such a function to remove all eventHandlers calls belonging to a given list picker on document. The goal is to do some cleanup when the list-picker is removed from the DOM (e.g like when you close a modal) How to test: - Open src/themes/tlp/doc/js/editors.js - find the updatePreview function, make it async - Now go to line 195 and modify the call to createListPicker like this: const list_picker = await createListPicker(document.querySelector("#list-picker-msb-error"), { placeholder: "Choose some values in the list", }); list_picker.destroy(); - Now, in your terminal, go to src and run `npm run build` - Once done, open the tlp doc and go to see the multi list pickers - Click to open the last one (#list-picker-msb-error) - Now press the Escape key --> The dropdown won't close - Now click outside the list picker --> The dropdown won't close - Do the same test with another list picker --> The dropdown closes if you press the escape key or click outside the list picker. Change-Id: I71706fc4e57e6d19e699917068f176963050b1d5

Modified Files

Name
M src/scripts/list-picker/src/helpers/EventManager.test.ts +18 −0 Go to diff View file
M src/scripts/list-picker/src/helpers/EventManager.ts +51 −24 Go to diff View file
M src/scripts/list-picker/src/list-picker.ts +6 −2 Go to diff View file
M src/scripts/list-picker/src/type.d.ts +4 −0 Go to diff View file