@txstate-mws/svelte-components 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/actions/resize.js
CHANGED
|
@@ -27,7 +27,7 @@ export function resize(el, config) {
|
|
|
27
27
|
if (!equal(lastSize, current)) {
|
|
28
28
|
lastSize = current;
|
|
29
29
|
if (config?.store)
|
|
30
|
-
config.store.
|
|
30
|
+
config.store.update(v => ({ ...v, ...current }));
|
|
31
31
|
el.dispatchEvent(new CustomEvent('resize', { detail: current }));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -41,7 +41,7 @@ export function resize(el, config) {
|
|
|
41
41
|
if (newConfig?.debounce === true)
|
|
42
42
|
newConfig.debounce = 100;
|
|
43
43
|
if (newConfig?.store !== config?.store) {
|
|
44
|
-
newConfig?.store?.
|
|
44
|
+
newConfig?.store?.update(v => ({ ...v, ...lastSize }));
|
|
45
45
|
}
|
|
46
46
|
if (!!newConfig?.debounce !== !!config?.debounce) {
|
|
47
47
|
observer.disconnect();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script >import { createEventDispatcher } from 'svelte';
|
|
2
|
-
import { randomid } from 'txstate-utils';
|
|
2
|
+
import { randomid, sleep } from 'txstate-utils';
|
|
3
3
|
import ScreenReaderOnly from './ScreenReaderOnly.svelte';
|
|
4
4
|
import DefaultPopupMenu from './PopupMenu.svelte';
|
|
5
5
|
import { debouncedPromise, modifierKey, selectionIsLeft } from '../util';
|
|
@@ -29,6 +29,8 @@ async function reactToInput(..._) {
|
|
|
29
29
|
if (inputvalue !== saveval)
|
|
30
30
|
return; // ignore any results that are out of date
|
|
31
31
|
options = rawOptions.filter(o => !selectedSet.has(o.value));
|
|
32
|
+
await sleep(100);
|
|
33
|
+
// needed to sleep a little bit or this will turn the menu on only to have popupmenu's click handler toggle it back off
|
|
32
34
|
if (typeof document !== 'undefined' && inputelement === document.activeElement)
|
|
33
35
|
menushown = true;
|
|
34
36
|
}
|
|
@@ -78,7 +80,7 @@ function inputkeydown(e) {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
function inputfocus() {
|
|
81
|
-
reactToInput();
|
|
83
|
+
reactToInput(true);
|
|
82
84
|
}
|
|
83
85
|
let popuphilited;
|
|
84
86
|
$: if (popuphilited != null)
|
|
@@ -99,7 +101,7 @@ $: dispatch('change', selected);
|
|
|
99
101
|
</script>
|
|
100
102
|
|
|
101
103
|
<fieldset>
|
|
102
|
-
<ul class="multiselect-selected" role="listbox"
|
|
104
|
+
<ul class="multiselect-selected" role="listbox">
|
|
103
105
|
{#each selected as option, i}
|
|
104
106
|
<li id={id + option.value} role="option" tabindex="-1" class="multiselect-pill" class:hilited={hilitedpill === option.value}
|
|
105
107
|
on:click|preventDefault|stopPropagation={() => removeSelection(option, i, 1)}
|
|
@@ -53,7 +53,8 @@ async function reactToMenuShown(_) {
|
|
|
53
53
|
else {
|
|
54
54
|
buttonelement.setAttribute('aria-controls', menuid);
|
|
55
55
|
buttonelement.setAttribute('aria-expanded', 'true');
|
|
56
|
-
buttonelement.
|
|
56
|
+
if (buttonelement !== document.activeElement)
|
|
57
|
+
buttonelement.focus();
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
$: reactToMenuShown(menushown);
|
|
@@ -149,7 +150,8 @@ function onbuttonclick(e) {
|
|
|
149
150
|
async function onblur(e) {
|
|
150
151
|
// tabindex=-1 on our menu elements means e.relatedTarget will be set
|
|
151
152
|
if (!(e.relatedTarget instanceof HTMLElement && menuelement?.contains(e.relatedTarget))) {
|
|
152
|
-
blurTimer = requestAnimationFrame(() => {
|
|
153
|
+
blurTimer = requestAnimationFrame(() => { if (buttonelement !== document.activeElement)
|
|
154
|
+
menushown = false; });
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
function cleanup(element) {
|