@larakit/react 0.5.0 → 0.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larakit/react",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Larakit's React components and pages for Inertia.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@inertiajs/react": "^3",
20
- "@larakit/core": "0.5.0",
20
+ "@larakit/core": "0.5.1",
21
21
  "react": "^19"
22
22
  },
23
23
  "license": "MIT",
@@ -386,7 +386,9 @@ function DefaultModal({
386
386
  {children}
387
387
  </dialog>
388
388
  );
389
- return portal && typeof document !== 'undefined' ? createPortal(el, document.body) : el;
389
+ // Larakit's styles apply inside .larakit only, so a modal drawn elsewhere goes there, not to the bare body.
390
+ if (!portal || typeof document === 'undefined') return el;
391
+ return createPortal(el, document.querySelector('.larakit') ?? document.body);
390
392
  }
391
393
 
392
394
  export function Modal(props: ModalInternalProps) {
@@ -1662,6 +1662,16 @@ describe('Phase 3 standalone infolists, relation managers, and action modals', (
1662
1662
  expect(parentModal.hasAttribute('open')).toBe(true);
1663
1663
  stackHolder.remove();
1664
1664
  });
1665
+
1666
+ it('draws a confirm inside .larakit, where its styles apply', async () => {
1667
+ render(createElement(I18nProvider, { locale: 'en', children: createElement('div', { className: 'larakit' }, createElement(Notices)) }));
1668
+ const answer = sure('Save these changes?', 'Save', false);
1669
+ await waitFor(() => expect(document.querySelector('dialog[data-lk="confirm"][open]')).toBeTruthy());
1670
+ const dialog = document.querySelector('dialog[data-lk="confirm"][open]')!;
1671
+ expect(dialog.closest('.larakit')).toBeTruthy();
1672
+ fireEvent.keyDown(dialog, { key: 'Escape' });
1673
+ await expect(answer).resolves.toBe(false);
1674
+ });
1665
1675
  });
1666
1676
 
1667
1677
  describe('Phase 4 multi-tenancy and dashboard widget upgrades', () => {