* feat(ctrl-click): Enable Ctrl-Click on suggestions This updates the underlying autocomplete.js to a version that passes the selection context (click or keyboard) to the `autocomplete:selected` event. With the default `handleSelected, and in the case of a click, it will do nothing (as each suggestion already being a `<a href>`, it will already follow the link), but manually change the location for keyboard navigation. When a custom `handleSelected` is set though, default browser clicks on suggestions are disabled and only `handleSelected` is called. This is to keep backward compatibility with all the live websites that might already use `handleSelected`. * fix(test): Making sure it does not crash when no context is passed
53 lines
1.4 KiB
HTML
53 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>DocSearch playground</title>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" />
|
|
<link rel="stylesheet" href="http://127.0.0.1:8080/docsearch.min.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<div class="mt-1">
|
|
<h1>Assets are served from http://127.0.0.1:8080/ </h1>
|
|
</div>
|
|
<div class="col-md-12">
|
|
<div class="input-group">
|
|
<input type="search" placeholder="DocSearch input" class="form-control" id="q">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- at the end of the BODY -->
|
|
<script src="http://127.0.0.1:8080/docsearch.js"></script>
|
|
<script>
|
|
docsearch({
|
|
apiKey: '25626fae796133dc1e734c6bcaaeac3c',
|
|
indexName: 'docsearch',
|
|
inputSelector: '#q',
|
|
handleSelected(input, event, suggestion, datasetNumber, context) {
|
|
console.info(input);
|
|
console.info(event);
|
|
console.info(suggestion);
|
|
console.info(datasetNumber);
|
|
console.info(context);
|
|
},
|
|
debug: true // Set debug to true if you want to inspect the dropdown
|
|
});
|
|
</script>
|
|
<style>
|
|
|
|
.container {
|
|
margin: 10%;
|
|
}
|
|
|
|
.input-group {
|
|
width: 60%;
|
|
margin: auto;
|
|
margin-top: 10%;
|
|
}
|
|
</style>
|
|
</body>
|
|
|
|
</html>
|