Skip to content

fix(modal): add icon status style #3504

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

Merged
merged 1 commit into from
Jun 17, 2025
Merged
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
8 changes: 6 additions & 2 deletions packages/vue/src/modal/src/mobile-first.vue
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,12 @@ export default defineComponent({
tiny_mode: 'mobile-first'
},
class: [
'inline-block sm:hidden mr-1.5 fill-current',
type === 'message' ? 'w-5 h-5 self-center shrink-0' : 'h-6 w-auto'
'h-4 w-4 inline-block sm:hidden mr-1.5 fill-current',
type === 'message' ? 'w-5 h-5 self-center shrink-0' : 'h-6 w-auto',
{ 'text-color-success': status === 'success' },
{ 'text-color-info-secondary': ['info', 'question'].includes(status) },
{ 'text-color-warning': status === 'warning' },
{ 'text-color-error': status === 'error' }
Comment on lines +364 to +369
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Status-matching is case-sensitive → colour classes silently break when status is upper-case

statusIcon / mobileStatusIcon are resolved with status.toUpperCase(), but the colour classes still compare against lower-case literals ('success', 'warning', …).
If the caller passes 'SUCCESS' or 'Warning', the icon shows up, yet the colour class is not applied – an easy-to-miss visual bug.

Refactor once so both the icon mapping and colour classes use the same normalised value; it also removes the duplication between desktop & mobile blocks.

@@
-      status,
+      // normalise status once for icon mapping & CSS utility checks
+      status,
+      statusUpper = typeof status === 'string' ? status.toUpperCase() : '',
+      statusLower = typeof status === 'string' ? status.toLowerCase() : '',
@@
-    const statusIcon = typeof status === 'string' ? STATUS_MAPPING_COMPINENT[status.toUpperCase()] : status
-    const mobileStatusIcon = typeof status === 'string' ? MOBILE_STATUS_MAPPING_COMPINENT[status.toUpperCase()] : status
+    const statusIcon =
+      typeof status === 'string' ? STATUS_MAPPING_COMPINENT[statusUpper] : status
+    const mobileStatusIcon =
+      typeof status === 'string' ? MOBILE_STATUS_MAPPING_COMPINENT[statusUpper] : status
@@
-                                    { 'text-color-success': status === 'success' },
-                                    { 'text-color-info-secondary': ['info', 'question'].includes(status) },
-                                    { 'text-color-warning': status === 'warning' },
-                                    { 'text-color-error': status === 'error' }
+                                    { 'text-color-success': statusLower === 'success' },
+                                    { 'text-color-info-secondary': ['info', 'question'].includes(statusLower) },
+                                    { 'text-color-warning': statusLower === 'warning' },
+                                    { 'text-color-error': statusLower === 'error' }

This keeps behaviour unchanged for correctly-cased inputs while fixing upper-/mixed-case ones and DRYs up the comparisons.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/vue/src/modal/src/mobile-first.vue around lines 364 to 369, the
status string is compared in a case-sensitive way for applying colour classes,
causing issues when status is upper- or mixed-case. Normalize the status value
to a consistent case (e.g., lowercase) once before these comparisons and use
this normalized value both for icon resolution and colour class conditions. This
will fix the colour class application for all case variations and reduce
duplication between desktop and mobile icon handling.

]
})
]
Expand Down
Loading