@classic-homes/theme-react 0.3.1 → 0.3.2

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/dist/index.js CHANGED
@@ -2148,10 +2148,13 @@ function InsertPalette({
2148
2148
  renderThumbnail
2149
2149
  }) {
2150
2150
  const [query, setQuery] = React22.useState("");
2151
+ const picked = React22.useRef(false);
2151
2152
  const listRef = React22.useRef(null);
2152
2153
  const searchRef = React22.useRef(null);
2153
2154
  React22.useEffect(() => {
2154
- if (open) setQuery("");
2155
+ if (!open) return;
2156
+ setQuery("");
2157
+ picked.current = false;
2155
2158
  }, [open]);
2156
2159
  const q = query.trim().toLowerCase();
2157
2160
  const filtered = q ? groups.map((g) => ({
@@ -2165,6 +2168,7 @@ function InsertPalette({
2165
2168
  const firstMatch = filtered.flatMap((g) => g.items).find((i) => !i.disabled);
2166
2169
  const choose = (item) => {
2167
2170
  if (item.disabled) return;
2171
+ picked.current = true;
2168
2172
  onOpenChange(false);
2169
2173
  onSelect(item.id);
2170
2174
  };
@@ -2178,6 +2182,9 @@ function InsertPalette({
2178
2182
  e.preventDefault();
2179
2183
  searchRef.current?.focus();
2180
2184
  },
2185
+ onCloseAutoFocus: (e) => {
2186
+ if (picked.current) e.preventDefault();
2187
+ },
2181
2188
  ...description ? {} : { "aria-describedby": void 0 },
2182
2189
  children: [
2183
2190
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogTitle, { children: title }),
package/dist/index.mjs CHANGED
@@ -2039,10 +2039,13 @@ function InsertPalette({
2039
2039
  renderThumbnail
2040
2040
  }) {
2041
2041
  const [query, setQuery] = React22.useState("");
2042
+ const picked = React22.useRef(false);
2042
2043
  const listRef = React22.useRef(null);
2043
2044
  const searchRef = React22.useRef(null);
2044
2045
  React22.useEffect(() => {
2045
- if (open) setQuery("");
2046
+ if (!open) return;
2047
+ setQuery("");
2048
+ picked.current = false;
2046
2049
  }, [open]);
2047
2050
  const q = query.trim().toLowerCase();
2048
2051
  const filtered = q ? groups.map((g) => ({
@@ -2056,6 +2059,7 @@ function InsertPalette({
2056
2059
  const firstMatch = filtered.flatMap((g) => g.items).find((i) => !i.disabled);
2057
2060
  const choose = (item) => {
2058
2061
  if (item.disabled) return;
2062
+ picked.current = true;
2059
2063
  onOpenChange(false);
2060
2064
  onSelect(item.id);
2061
2065
  };
@@ -2069,6 +2073,9 @@ function InsertPalette({
2069
2073
  e.preventDefault();
2070
2074
  searchRef.current?.focus();
2071
2075
  },
2076
+ onCloseAutoFocus: (e) => {
2077
+ if (picked.current) e.preventDefault();
2078
+ },
2072
2079
  ...description ? {} : { "aria-describedby": void 0 },
2073
2080
  children: [
2074
2081
  /* @__PURE__ */ jsx24(DialogTitle, { children: title }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-react",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "React components for the Classic theme system",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",