@openlettermarketing/olc-react-sdk 2.1.5-beta.8 → 2.1.5-beta.9

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.
@@ -1 +1 @@
1
- export const SDK_VERSION: "2.1.5-beta.8";
1
+ export const SDK_VERSION: "2.1.5-beta.9";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openlettermarketing/olc-react-sdk",
3
3
  "private": false,
4
- "version": "2.1.5-beta.8",
4
+ "version": "2.1.5-beta.9",
5
5
  "type": "module",
6
6
  "description": "Simplify template builder integration for any product.",
7
7
  "main": "build/index.js",
@@ -625,11 +625,11 @@ const CustomQRCode = {
625
625
  const handleEditQRCode = async (qrCode: any) => {
626
626
  setIsEditing(true);
627
627
  setSelectedQR(qrCode);
628
- dispatch(setQrUrl(qrCode.url ?? ''));
629
- dispatch(setUtmSource(qrCode.utm_source ?? ''));
630
- dispatch(setUtmMedium(qrCode.utm_medium ?? ''));
631
- dispatch(setUtmCampaignName(qrCode.utm_campaign_name ?? ''));
632
- dispatch(setCustomUtms(qrCode.custom_utms ?? {}));
628
+ dispatch(setQrUrl(qrCode.url));
629
+ dispatch(setUtmSource(qrCode.utmSource || 'direct mail'));
630
+ dispatch(setUtmMedium(qrCode.utmMedium || 'QR Code'));
631
+ dispatch(setUtmCampaignName(qrCode.utm_campaign_name || ''));
632
+ dispatch(setCustomUtms(qrCode.custom_utms || {}));
633
633
 
634
634
  handleDialogChange('qr-modal');
635
635
  setIsActionsOpen(null);
@@ -678,8 +678,8 @@ const CustomQRCode = {
678
678
  name: utmCampaignName,
679
679
  url: url,
680
680
  qrImagePath: uploadedFile,
681
- utm_source: utmSource || null,
682
- utm_medium: utmMedium || null,
681
+ utm_source: utmSource,
682
+ utm_medium: utmMedium,
683
683
  utm_campaign_name: utmCampaignName,
684
684
  custom_utms: customUtms,
685
685
  },
@@ -172,8 +172,12 @@ const CustomTemplateSection: SideSection = {
172
172
  const [myTemplates, setMyTemplates] = useState<TemplateRecord[]>([]);
173
173
  const [teamTemplates, setTeamTemplates] = useState<TemplateRecord[]>([]);
174
174
  const [olcTemplates, setOlcTemplates] = useState<TemplateRecord[]>([]);
175
- const [searchApplied, setSearchApplied] = useState(false);
176
- const [search, setSearch] = useState('');
175
+ // Initialise from localStorage so state survives the MobX-driven unmount/remount
176
+ // that occurs when the user switches browser tabs and returns.
177
+ const [searchApplied, setSearchApplied] = useState(
178
+ getItem('gallerySearchApplied') === 'true'
179
+ );
180
+ const [search, setSearch] = useState(getItem('gallerySearch') || '');
177
181
  const [loader, setLoader] = useState(false);
178
182
  const [pagination, setPagination] = useState({
179
183
  count: 0,
@@ -316,6 +320,11 @@ const CustomTemplateSection: SideSection = {
316
320
  setOpenGalleryModal(false);
317
321
  store.openSidePanel(selectedSection || 'text');
318
322
  removeItem('currentTab');
323
+ // Clear persisted search so the gallery opens fresh next time.
324
+ setSearch('');
325
+ setSearchApplied(false);
326
+ removeItem('gallerySearch');
327
+ removeItem('gallerySearchApplied');
319
328
  document.body.classList.remove('no-scroll');
320
329
  };
321
330
 
@@ -342,12 +351,19 @@ const CustomTemplateSection: SideSection = {
342
351
  const handleSearch = () => {
343
352
  if (search) {
344
353
  setSearchApplied(true);
354
+ setItem('gallerySearchApplied', 'true');
345
355
  getTemplatesByTab();
346
356
  }
347
357
  };
348
358
 
349
359
  const removeSearchInput = () => {
350
360
  setSearch('');
361
+ // Do NOT call setSearchApplied(false) here — React 18 batches both state updates
362
+ // into one render, making searchApplied already false when useEffect([search]) runs,
363
+ // which prevents the condition (!search && searchApplied) from firing and skips
364
+ // the re-fetch. The useEffect below owns that transition.
365
+ removeItem('gallerySearch');
366
+ removeItem('gallerySearchApplied');
351
367
  };
352
368
 
353
369
  const searchKeyDown = (event: any) => {
@@ -543,7 +559,8 @@ const CustomTemplateSection: SideSection = {
543
559
  useEffect(() => {
544
560
  if (!search && searchApplied) {
545
561
  setSearchApplied(false);
546
- setSearch('');
562
+ removeItem('gallerySearch');
563
+ removeItem('gallerySearchApplied');
547
564
  setTimeout(() => {
548
565
  getTemplatesByTab();
549
566
  }, 100);
@@ -552,6 +569,8 @@ const CustomTemplateSection: SideSection = {
552
569
 
553
570
  useEffect(() => {
554
571
  searchRef.current = search;
572
+ // Keep localStorage in sync so the value survives tab-switch remounts.
573
+ setItem('gallerySearch', search);
555
574
  }, [search]);
556
575
 
557
576
  useEffect(() => {
package/version.js CHANGED
@@ -1 +1 @@
1
- export const SDK_VERSION = '2.1.5-beta.8';
1
+ export const SDK_VERSION = '2.1.5-beta.9';