Repository navigation
fix: support click model card to edit #7870
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ const props = defineProps<{ | |
| shared: boolean | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ click: [event: MouseEvent] }>() | ||
|
|
||
| defineSlots<{ 'action-dropdown'?: () => unknown }>() | ||
|
|
||
| const errMessage = computed(() => { | ||
|
|
@@ -30,10 +32,22 @@ const errMessage = computed(() => { | |
| } | ||
| return '' | ||
| }) | ||
|
|
||
| function handleClick(event: MouseEvent) { | ||
| if (props.disabled) return | ||
| emit('click', event) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <MkResourceCard class="relative overflow-hidden" :title="model.name" :nick_name="model.nick_name || '-'" :create_time="model.create_time"> | ||
| <MkResourceCard | ||
| class="relative overflow-hidden" | ||
| :disabled="disabled" | ||
| :title="model.name" | ||
| :nick_name="model.nick_name || '-'" | ||
| :create_time="model.create_time" | ||
| @click="handleClick" | ||
| > | ||
| <template #icon> | ||
| <span class="block h-6 w-6" :innerHTML="provider.icon" /> | ||
| </template> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an analysis of the code diff provided: 1. Potential Issue: HTML Injection RiskLocation: <span class="block h-6 w-6" :innerHTML="provider.icon" />Issue: Using 2. Typo/Vue 3 API ConsistencyLocation: 3. Missing Prop Definition for
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff is structurally reasonable: it replaces a per-card edit action with one shared
EditModelDrawer, and theeditDrawerMountedguard prevents duplicate drawer mounts. However, there are several issues to verify/fix.1. Event bubbling is the main risk
Adding
@clickto the whole card will also receive clicks from interactive children inside the card, especially the action-dropdown trigger and any buttons/icons. That means:.../ action menu trigger may also open the edit drawer;Fix by either:
@click.stopto the action-dropdown trigger and all interactive controls insideModelCard.Also verify that
ModelCardhas a single root element. If it is a fragment/multi-root component, the nativeclicklistener may not fall through as expected.2. Verify the
EditModelDrawercontractThe new code assumes that
EditModelDrawer:open(provider, model)method viadefineExpose;closed;refresh;apiprop.If any of these is missing or named differently, the drawer may never open, never unmount, or never refresh the list.
If the drawer uses
v-model/update:modelValueinstead ofclosed, theneditDrawerMountedwill never be reset. That would permanently block future edit attempts.3.
editDrawerMountedcan get stuckIf the ref is
null, or ifopen()throws,editDrawerMountedremainstrue, and all future edit clicks are ignored. Use a safer version:If
open()is synchronous, thetry/catchis still useful;awaitcan be removed if it is not async.4.
useTemplateRefrequires Vue 3.5+This is fine on Vue 3.5+, but will not work on older Vue 3 versions. Confirm the project version. If the project is on Vue < 3.5, use:
5. Verify
MkActionis availableSince
EditModelActionwas removed, verify thatMkActionis globally registered or auto-imported. Also verify that it accepts theiconprop and that clicking it closes the dropdown as expected.6. Accessibility / UX concern
A whole card with
@clickis not keyboard-accessible unless it has properrole,tabindex, andkeydown.enter/keydown.spacehandling. A dedicated edit button inside the dropdown is safer and clearer. At minimum, avoid making the card look clickable when the user lacks modify permission or whenisSharedis true.7. Minor optimization
The formatting-only changes to
ButtonAddModel,ParamSettingAction, andRelatedResourcesModelActionincrease diff noise. They are harmless, but can be omitted to keep the review focused.Summary
The biggest issue is the whole-card
@clickcombined with an action dropdown inside the card. Add@click.stopon interactive card children or use a dedicated edit trigger. Then verify the drawer exposesopen, emitsclosed/refresh, and thateditDrawerMountedis reset if opening fails.