fix: location context menu does not remove external classes from location node

This commit is contained in:
pa
2026-03-26 00:12:53 +09:00
parent 807e39ce72
commit 1a7f9ca952
2 changed files with 29 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
<template>
<component :is="enableContextMenu ? ContextMenu : Passthrough">
<component :is="enableContextMenu ? ContextMenuTrigger : Passthrough" as-child>
<div class="cursor-pointer">
<div class="cursor-pointer" v-bind="$attrs">
<div v-if="!text" class="text-transparent">-</div>
<div v-show="text" class="flex items-center">
<template v-if="isAgeRestricted">
@@ -83,6 +83,10 @@
import WorldActionMenuItems from './WorldActionMenuItems.vue';
import { accessTypeLocaleKeyMap } from '../shared/constants';
defineOptions({
inheritAttrs: false
});
const Passthrough = (_, { slots }) => slots.default?.();
const { t } = useI18n();

View File

@@ -112,6 +112,10 @@ const i18n = createI18n({
});
const stubs = {
ContextMenu: { template: '<div><slot /></div>' },
ContextMenuTrigger: { template: '<div><slot /></div>' },
ContextMenuContent: { template: '<div><slot /></div>' },
WorldActionMenuItems: { template: '<div />' },
TooltipWrapper: {
template: '<span><slot /></span>',
props: [
@@ -126,9 +130,10 @@ const stubs = {
AlertTriangle: { template: '<span class="alert-triangle" />' }
};
function mountLocation(props = {}, appearanceOverrides = {}) {
function mountLocation(props = {}, appearanceOverrides = {}, mountOptions = {}) {
return mount(Location, {
props,
...mountOptions,
global: {
plugins: [
i18n,
@@ -185,6 +190,24 @@ describe('Location.vue', () => {
});
});
describe('context menu attrs', () => {
test('keeps external classes on the visible location node when context menu is enabled', () => {
const wrapper = mountLocation(
{ location: 'wrld_12345:67890', enableContextMenu: true },
{},
{
attrs: {
class: 'text-xs custom-location'
}
}
);
const locationNode = wrapper.find('.custom-location');
expect(locationNode.exists()).toBe(true);
expect(locationNode.classes()).toContain('text-xs');
});
});
describe('hint display', () => {
test('shows hint with access type for valid instance', () => {
const wrapper = mountLocation({