@dnax/ui 0.0.71 → 0.0.72
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/components/QSpreadsheet.vue +19 -6
- package/package.json +1 -1
|
@@ -782,6 +782,8 @@ const moveSelection = (dr: number, dc: number, extend = false) => {
|
|
|
782
782
|
const escAttr = (s: string) => String(s).replace(/"/g, '\\"')
|
|
783
783
|
const scrollEl = ref<HTMLElement | null>(null)
|
|
784
784
|
const rootEl = ref<HTMLElement | null>(null)
|
|
785
|
+
/** Racine du composant (pour distinguer un clic intérieur d'un clic extérieur) */
|
|
786
|
+
const rootRef = ref<HTMLElement | null>(null)
|
|
785
787
|
const setGridRef = (el: unknown) => {
|
|
786
788
|
rootEl.value = (el as HTMLElement) ?? null
|
|
787
789
|
scrollEl.value = (el as HTMLElement) ?? null
|
|
@@ -1138,7 +1140,7 @@ const coerceValue = (col: QSpreadsheetColumn | undefined, text: unknown, old: an
|
|
|
1138
1140
|
return raw
|
|
1139
1141
|
}
|
|
1140
1142
|
|
|
1141
|
-
const commitEdit = async () => {
|
|
1143
|
+
const commitEdit = async (options: { focus?: boolean } = {}) => {
|
|
1142
1144
|
if (!editing.value) return
|
|
1143
1145
|
const { row, column } = editing.value
|
|
1144
1146
|
const col = colOf(column)
|
|
@@ -1149,7 +1151,10 @@ const commitEdit = async () => {
|
|
|
1149
1151
|
const next = col?.type === "multiselect" ? old : coerceValue(col, text, old)
|
|
1150
1152
|
editing.value = null
|
|
1151
1153
|
emit("cell-edit-end", { row, column, canceled: false })
|
|
1152
|
-
|
|
1154
|
+
// Le focus n'est **pas** restauré par défaut : un `blur` (clic hors de la grille)
|
|
1155
|
+
// ne doit pas voler le focus à l'élément cliqué. Seuls les appels internes qui le
|
|
1156
|
+
// demandent explicitement (`pickOption`) le font.
|
|
1157
|
+
if (options.focus) nextTick(() => focusCell(row, column))
|
|
1153
1158
|
if (next !== old) await validateAndSet(row, column, old, next)
|
|
1154
1159
|
}
|
|
1155
1160
|
|
|
@@ -1914,7 +1919,8 @@ watch(selectOptions, () => {
|
|
|
1914
1919
|
})
|
|
1915
1920
|
const pickOption = (opt: QSpreadsheetCellOption) => {
|
|
1916
1921
|
draft.value = String(opt.label ?? "")
|
|
1917
|
-
|
|
1922
|
+
// Choix fait **dans** la liste : le focus revient utilement à la cellule
|
|
1923
|
+
commitEdit({ focus: true })
|
|
1918
1924
|
}
|
|
1919
1925
|
|
|
1920
1926
|
/** Valeur courante (tableau) de la cellule à choix multiples en cours d'édition */
|
|
@@ -2803,6 +2809,13 @@ const onColContext = (ci: number, e: MouseEvent) => {
|
|
|
2803
2809
|
const onDocPointerDown = (e: PointerEvent) => {
|
|
2804
2810
|
const t = e.target as HTMLElement
|
|
2805
2811
|
if (!t || !t.closest) return
|
|
2812
|
+
// Un clic **hors de l'éditeur** ferme l'édition — sans lui voler le focus :
|
|
2813
|
+
// le `blur` ne suffit pas si la cible n'est pas focusable (fond de page, `<div>`…).
|
|
2814
|
+
// Condition : ne rien faire seulement si le clic est dans **notre** éditeur (une autre
|
|
2815
|
+
// instance du tableur peut avoir le sien ouvert).
|
|
2816
|
+
if (editing.value && !(rootRef.value?.contains(t) && t.closest(".q-spreadsheet__editor"))) {
|
|
2817
|
+
commitEdit()
|
|
2818
|
+
}
|
|
2806
2819
|
if (
|
|
2807
2820
|
(ctxMenu.value && !t.closest(".q-spreadsheet__ctx")) ||
|
|
2808
2821
|
(filterMenu.value && !t.closest(".q-spreadsheet__fpop") && !t.closest(".q-spreadsheet__fbtn"))
|
|
@@ -4617,7 +4630,7 @@ defineExpose({
|
|
|
4617
4630
|
</script>
|
|
4618
4631
|
|
|
4619
4632
|
<template>
|
|
4620
|
-
<div class="q-spreadsheet" :class="rootClasses" :style="radiusStyle(effectiveRadius)">
|
|
4633
|
+
<div ref="rootRef" class="q-spreadsheet" :class="rootClasses" :style="radiusStyle(effectiveRadius)">
|
|
4621
4634
|
<!-- ═══════ Onglets de feuilles (classeur, haut) ═══════ -->
|
|
4622
4635
|
<div
|
|
4623
4636
|
v-if="sheetsMode && sheetsPosition === 'top'"
|
|
@@ -5152,7 +5165,7 @@ defineExpose({
|
|
|
5152
5165
|
@keyup="syncEditCaret"
|
|
5153
5166
|
@click="syncEditCaret"
|
|
5154
5167
|
@keydown="onEditKeydown"
|
|
5155
|
-
@blur="commitEdit"
|
|
5168
|
+
@blur="commitEdit()"
|
|
5156
5169
|
/>
|
|
5157
5170
|
<input
|
|
5158
5171
|
v-else
|
|
@@ -5163,7 +5176,7 @@ defineExpose({
|
|
|
5163
5176
|
:inputmode="editorInputMode"
|
|
5164
5177
|
:placeholder="editingIsSelect ? 'Type to filter…' : editingIsMulti ? 'Filter options…' : ''"
|
|
5165
5178
|
@keydown="onEditKeydown"
|
|
5166
|
-
@blur="commitEdit"
|
|
5179
|
+
@blur="commitEdit()"
|
|
5167
5180
|
/>
|
|
5168
5181
|
<div v-if="editingIsFormula && fxHint && !fxOpen" class="q-spreadsheet__fxhint q-spreadsheet__fxhint--editor">
|
|
5169
5182
|
<strong>{{ fxHint.name }}</strong>(<template v-for="(arg, i) in fxHint.args" :key="i"><span
|