Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): modify the issue of the mobile demo not displaying and reporting errors #2710

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/mobile/components/tabs/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import type { ITabsRenderlessParams, ITabsPane, ITabsCustomEvent, ITabsPaneVm }
export const calcPaneInstances =
({
constants,
parent,
vm,
state,
childrenHandler
}: Pick<ITabsRenderlessParams, 'constants' | 'parent' | 'state' | 'childrenHandler'>) =>
}: Pick<ITabsRenderlessParams, 'constants' | 'vm' | 'state' | 'childrenHandler'>) =>
(isForceUpdate = false) => {
const tabItemVNodes = parent.$slots.default
const tabItemVNodes = vm.$slots.default

/* istanbul ignore if */
if (tabItemVNodes) {
Expand Down Expand Up @@ -62,13 +62,13 @@ export const calcPaneInstances =

/* istanbul ignore */
export const calcMorePanes =
({ parent, props, state, refs }: Pick<ITabsRenderlessParams, 'parent' | 'props' | 'state' | 'refs'>) =>
({ vm, props, state, refs }: Pick<ITabsRenderlessParams, 'vm' | 'props' | 'state' | 'refs'>) =>
() => {
if (!props.showMoreTabs) {
return
}

const el = parent.$el
const el = vm.$el
const tabs = el.querySelectorAll('.tiny-tabs__item')
const tabNavRefs = refs.nav.$refs

Expand All @@ -93,12 +93,12 @@ export const calcMorePanes =
}

export const calcExpandPanes =
({ parent, props, state }: Pick<ITabsRenderlessParams, 'parent' | 'props' | 'state'>) =>
({ vm, props, state }: Pick<ITabsRenderlessParams, 'vm' | 'props' | 'state'>) =>
() => {
if (!props.showExpandTabs) {
return
}
const el = parent.$el
const el = vm.$el
const tabsHeader = el.querySelector('.tiny-mobile-tabs__header')

if (tabsHeader) {
Expand Down Expand Up @@ -185,11 +185,11 @@ export const changeCurrentName =
}

export const created =
({ api, parent, state }: Pick<ITabsRenderlessParams, 'api' | 'parent' | 'state'>) =>
({ api, vm, state }: Pick<ITabsRenderlessParams, 'api' | 'vm' | 'state'>) =>
() => {
api.changeDirection(state.currentName)

parent.$on('tab-nav-update', api.calcPaneInstances.bind(null, true))
vm.$on('tab-nav-update', api.calcPaneInstances.bind(null, true))
}

export const changeDirection =
Expand Down
12 changes: 6 additions & 6 deletions packages/mobile/components/tabs/src/renderless/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const initWatcher = ({
export const renderless = (
props: ITabsProps,
{ onMounted, onUpdated, provide, reactive, watch }: ISharedRenderlessParamHooks,
{ refs, parent, emit, constants, nextTick, childrenHandler }: ITabsRenderlessParamUtils
{ refs, parent, vm, emit, constants, nextTick, childrenHandler }: ITabsRenderlessParamUtils
): ITabsApi => {
const api = {} as ITabsApi
const state: ITabsState = initState({ reactive, props })
Expand All @@ -113,20 +113,20 @@ export const renderless = (
handleTabRemove: handleTabRemove({ emit, props }),
changeDirection: changeDirection({ props, state }),
changeCurrentName: changeCurrentName({ emit, state }),
calcMorePanes: calcMorePanes({ parent, props, state, refs }),
calcExpandPanes: calcExpandPanes({ parent, props, state }),
calcPaneInstances: calcPaneInstances({ constants, parent, state, childrenHandler }),
calcMorePanes: calcMorePanes({ vm, props, state, refs }),
calcExpandPanes: calcExpandPanes({ vm, props, state }),
calcPaneInstances: calcPaneInstances({ constants, vm, state, childrenHandler }),
handleTabDragStart: handleTabDragStart({ emit }),
handleTabDragOver: handleTabDragOver({ emit }),
handleTabDragEnd: handleTabDragEnd({ state, emit }),
handleTabClick: handleTabClick({ api, emit, props, refs }),
setCurrentName: setCurrentName({ api, props, refs, state }),
created: created({ api, parent, state })
created: created({ api, vm, state })
})

api.created()

provide('rootTabs', parent)
provide('rootTabs', vm)

provide('separator', state.separator)

Expand Down
Loading