Skip to content

Commit 9421e40

Browse files
committed
refactor: fixed useTemplateRef and @touchstart related warnings
1 parent 6ff3900 commit 9421e40

37 files changed

+93
-95
lines changed

apps/docs/src/stories/Components/Tooltip.story.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import { reactive, ref, type Ref, onMounted, useTemplateRef } from 'vue';
9696
import { PfButton } from '@vue-patternfly/core';
9797
import type { Placement } from '@vue-patternfly/core/helpers/FloatingUi.vue';
9898
99-
const buttonRef = useTemplateRef('buttonRef');
99+
const button = useTemplateRef('buttonRef');
100100
const trigger = reactive(['mouseenter', 'focus']);
101101
const leftAligned = ref(false);
102102
const flip = ref(true);
@@ -107,8 +107,8 @@ const exitDelay = ref(0);
107107
const distance = ref(15);
108108
109109
onMounted(() => {
110-
if (buttonRef.value?.el instanceof HTMLElement) {
111-
buttonRef.value.el.scrollIntoView({
110+
if (button.value?.el instanceof HTMLElement) {
111+
button.value.el.scrollIntoView({
112112
behavior: 'instant',
113113
block: 'center',
114114
inline: 'center',

packages/core/src/components/Alert/Alert.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div
33
v-if="!dismissed"
44
v-bind="ouiaProps"
5-
ref="el"
5+
ref="elRef"
66
:class="[
77
styles.alert,
88
styles.modifiers[variant], {
@@ -39,7 +39,7 @@
3939
<component :is="tooltipVisible ? PfTooltip : PassThrough" :position="tooltipPosition">
4040
<component
4141
:is="component"
42-
ref="titleRef"
42+
ref="title"
4343
:class="[styles.alertTitle, {
4444
[styles.modifiers.truncate]: truncateTitle,
4545
}]"
@@ -149,7 +149,7 @@ defineSlots<{
149149
'action-links'?: (props?: Record<never, never>) => any;
150150
}>();
151151
152-
const titleRef = useTemplateRef<HTMLElement | ComponentPublicInstance>('titleRef');
152+
const titleRef = useTemplateRef<HTMLElement | ComponentPublicInstance>('title');
153153
const { width, height } = useElementSize(titleRef);
154154
const tooltipVisible = ref(false);
155155
let timer: number | undefined = undefined;
@@ -158,7 +158,7 @@ const isMouseOver = ref(false);
158158
const timedOut = ref(false);
159159
const timedOutAnimation = ref(true);
160160
const containsFocus = ref(false);
161-
const el = useTemplateRef('el');
161+
const el = useTemplateRef('elRef');
162162
163163
const managedExpanded = useManagedProp('expanded', false);
164164
const variantLabel = computed(() => `${props.variant.charAt(0).toUpperCase()}${props.variant.slice(1)} alert:`);

packages/core/src/components/Button.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<component
1010
v-bind="{...ouiaProps, ...$attrs}"
1111
:is="buttonComponent"
12-
ref="el"
12+
ref="elRef"
1313
:type="buttonComponent === 'button' ? type : null"
1414
:disabled="effectiveDisabled"
1515
:aria-disabled="effectiveDisabled || ariaDisabled"
@@ -138,7 +138,7 @@ defineSlots<{
138138
badge?: (props?: Record<never, never>) => any;
139139
}>();
140140
141-
const el = useTemplateRef<HTMLElement | ComponentPublicInstance>('el');
141+
const el = useTemplateRef<HTMLElement | ComponentPublicInstance>('elRef');
142142
const ouiaProps = useOUIAProps({id: props.ouiaId, safe: props.ouiaSafe, variant: props.variant});
143143
144144
const buttonComponent = computed(() => {

packages/core/src/components/Checkbox.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<input
2626
:id="validId"
27-
ref="input"
27+
ref="inputRef"
2828
v-bind="$attrs"
2929
type="checkbox"
3030
:class="styles.checkInput"
@@ -96,7 +96,7 @@ defineSlots<{
9696
}>();
9797
9898
useChildrenTracker(FormInputsKey, getCurrentInstance()?.proxy);
99-
const input = useTemplateRef('input');
99+
const input = useTemplateRef('inputRef');
100100
const wrapWithLabel = computed(() => (props.labelWrapped && !props.component) || props.component === 'label');
101101
const validId = computed(() => props.id || getUniqueId());
102102

packages/core/src/components/ChipGroup/Chip.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
:type="component === 'button' ? 'button' : undefined"
3535
>
3636
<span :class="styles.chipContent">
37-
<span :id="effectiveId" ref="textRef" :class="styles.chipText">
37+
<span :id="effectiveId" ref="text" :class="styles.chipText">
3838
<slot />
3939
</span>
4040
<slot name="badge" />
@@ -100,7 +100,7 @@ defineSlots<{
100100
badge?: (props?: Record<never, never>) => any;
101101
}>();
102102
103-
const textRef = useTemplateRef('textRef');
103+
const textRef = useTemplateRef('text');
104104
const textOverflowing = useElementOverflow(textRef);
105105
const effectiveId = computed(() => props.id ?? getUniqueId());
106106
</script>

packages/core/src/components/ChipGroup/ChipGroup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{ category }}
1414
</template>
1515

16-
<span ref="labelRef" :class="styles.chipGroupLabel">
16+
<span ref="label" :class="styles.chipGroupLabel">
1717
{{ category }}
1818
</span>
1919
</pf-tooltip>
@@ -84,7 +84,7 @@ const slots = defineSlots<{
8484
default?: (props?: Record<never, never>) => any;
8585
}>();
8686
87-
const labelRef = useTemplateRef('labelRef');
87+
const labelRef = useTemplateRef('label');
8888
const labelOverflowing = useElementOverflow(labelRef);
8989
const open = ref(props.defaultOpen);
9090

packages/core/src/components/DescriptionList/DescriptionListTermHelpTextButton.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ defineSlots<{
3030
default?: (props?: Record<never, never>) => any;
3131
}>();
3232
33-
const helpTextRef = useTemplateRef('helpTextRef');
33+
const helpText = useTemplateRef('helpTextRef');
3434
3535
function handleKeys(event: KeyboardEvent) {
36-
if (!helpTextRef.value || helpTextRef.value !== (event.target as HTMLElement)) {
36+
if (!helpText.value || helpText.value !== (event.target as HTMLElement)) {
3737
return;
3838
}
3939
4040
const key = event.key;
4141
if (key === 'Enter' || key === ' ') {
4242
event.preventDefault();
43-
helpTextRef.value.click();
43+
helpText.value.click();
4444
}
4545
}
4646
</script>

packages/core/src/components/Drawer/Drawer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
v-bind="ouiaProps"
4-
ref="el"
4+
ref="elRef"
55
:class="[styles.drawer, {
66
[styles.modifiers.expanded]: expandedClass,
77
[styles.modifiers.inline]: inline,
@@ -50,7 +50,7 @@ defineSlots<{
5050
default?: (props?: Record<never, never>) => any;
5151
}>();
5252
53-
const el = useTemplateRef('el');
53+
const el = useTemplateRef('elRef');
5454
const display = ref(props.static || props.expanded);
5555
const expandedClass = ref(props.expanded);
5656
const isOpen = computed(() => props.static || props.expanded);

packages/core/src/components/Drawer/DrawerContent.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<pf-drawer-main v-bind="ouiaProps">
33
<auto-wrap
4-
ref="el"
4+
ref="elRef"
55
force
66
component="div"
77
:exclude="PfDrawerPanelContent"
@@ -51,6 +51,6 @@ defineSlots<{
5151
content?: (props?: Record<never, never>) => any;
5252
}>();
5353
54-
const el = useTemplateRef('el');
54+
const el = useTemplateRef('elRef');
5555
provide(DrawerContentRefKey, el);
5656
</script>

packages/core/src/components/Drawer/DrawerPanelContent.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div
33
v-bind="ouiaProps"
44
:id="panelId"
5-
ref="panel"
5+
ref="panelRef"
66
:class="[styles.drawerPanel, {
77
[styles.modifiers.resizable]: resizable,
88
[styles.modifiers.noBorder]: noBorder,
@@ -104,7 +104,7 @@ defineSlots<{
104104
default?: (props?: Record<never, never>) => any;
105105
}>();
106106
107-
const panel = useTemplateRef('panel');
107+
const panel = useTemplateRef('panelRef');
108108
const panelId = computed(() => props.id || getUniqueId('pf-drawer-panel-'));
109109
110110
const drawerProvide = inject(DrawerKey);
@@ -115,7 +115,7 @@ if (!drawerProvide) {
115115
116116
const { el: drawerRef, position, expanded, display, inline } = drawerProvide;
117117
const drawerContentRef = inject(DrawerContentRefKey);
118-
const splitterRef = useTemplateRef('splitterRef');
118+
const splitter = useTemplateRef('splitterRef');
119119
120120
let isResizing: boolean | null = null;
121121
const panelSize: Ref<number | undefined> = ref();
@@ -130,7 +130,7 @@ function calcValueNow() {
130130
const drawerContentEl = resolveOverridableComponent(drawerContentRef?.value);
131131
132132
const paR = panel.value?.getBoundingClientRect() ?? { left: 0, right: 0 };
133-
const spR = splitterRef.value?.getBoundingClientRect() ?? { left: 0, right: 0, top: 0, bottom: 0 };
133+
const spR = splitter.value?.getBoundingClientRect() ?? { left: 0, right: 0, top: 0, bottom: 0 };
134134
const drR = drawerRef.value?.getBoundingClientRect() ?? { left: 0, right: 0 };
135135
const dCR = drawerContentEl?.getBoundingClientRect() ?? { left: 0, right: 0, top: 0, bottom: 0 };
136136

0 commit comments

Comments
 (0)