feat(Popup): export useGlobalZIndex and setGlobalZIndex (#13789)

Co-authored-by: cye2 <cye2@leqee.com>
This commit is contained in:
Mrbigshot
2026-03-26 22:44:59 +08:00
committed by GitHub
parent 368b226417
commit 83aa18ee3a
2 changed files with 31 additions and 1 deletions
+4
View File
@@ -4,6 +4,10 @@ import _Popup from './Popup';
export const Popup = withInstall(_Popup);
export default Popup;
export { popupProps } from './Popup';
export {
useGlobalZIndex,
setGlobalZIndex,
} from '../composables/use-global-z-index';
export type { PopupProps } from './Popup';
export type {
PopupPosition,
+27 -1
View File
@@ -1,6 +1,6 @@
import { nextTick } from 'vue';
import { mount, triggerDrag } from '../../../test';
import { Popup } from '..';
import { Popup, useGlobalZIndex, setGlobalZIndex } from '..';
let wrapper;
afterEach(() => {
@@ -303,3 +303,29 @@ test('should destroy content when using destroyOnClose prop', async () => {
await wrapper.setProps({ show: false });
expect(wrapper.find('.foo').exists()).toBeFalsy();
});
test('useGlobalZIndex should return auto-incrementing z-index', () => {
setGlobalZIndex(2000);
const first = useGlobalZIndex();
const second = useGlobalZIndex();
const third = useGlobalZIndex();
expect(first).toBe(2001);
expect(second).toBe(2002);
expect(third).toBe(2003);
});
test('setGlobalZIndex should reset the global z-index', () => {
setGlobalZIndex(100);
expect(useGlobalZIndex()).toBe(101);
expect(useGlobalZIndex()).toBe(102);
setGlobalZIndex(500);
expect(useGlobalZIndex()).toBe(501);
expect(useGlobalZIndex()).toBe(502);
});
test('setGlobalZIndex should allow custom initial value', () => {
setGlobalZIndex(0);
expect(useGlobalZIndex()).toBe(1);
expect(useGlobalZIndex()).toBe(2);
});