From f8c0bf13d58b76ee95616d7317a99115802fa52e Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 3 Jun 2026 15:26:50 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui)=20:=20InputPhone=20readonly=20suit=20l?= =?UTF-8?q?es=20r=C3=A8gles=20readonly=20(plus=20de=20look=20disabled)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Découple readonly de disabled : le champ affiche border-black + curseur default, l'icône suit text-black/text-m-muted selon isFilled, et le bouton "add" conserve son guard onAdd sans porter l'apparence désactivée (opacity-40/cursor-not-allowed). Co-Authored-By: Claude Opus 4.8 (1M context) --- app/components/malio/input/InputPhone.test.ts | 26 +++++++++++++-- app/components/malio/input/InputPhone.vue | 32 +++++++++++++------ 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/app/components/malio/input/InputPhone.test.ts b/app/components/malio/input/InputPhone.test.ts index 67acfe7..b5903b4 100644 --- a/app/components/malio/input/InputPhone.test.ts +++ b/app/components/malio/input/InputPhone.test.ts @@ -274,10 +274,32 @@ describe('MalioInputPhone', () => { expect(wrapper.get('[data-test="add-button"]').attributes('disabled')).toBeDefined() }) - it('disables add button when readonly', () => { + it('add button is not natively disabled in readonly (onAdd guard blocks the action)', () => { const wrapper = mountComponent({addable: true, readonly: true}) - expect(wrapper.get('[data-test="add-button"]').attributes('disabled')).toBeDefined() + expect(wrapper.get('[data-test="add-button"]').attributes('disabled')).toBeUndefined() + }) + + it('readonly : border-black appliqué sur l\'input', () => { + const wrapper = mountComponent({label: 'Tel', readonly: true}) + expect(wrapper.get('input').classes()).toContain('border-black') + }) + + it('readonly : icône en text-m-muted quand vide', () => { + const wrapper = mountComponent({label: 'Tel', readonly: true}) + expect(wrapper.get('[data-test="icon"]').classes()).toContain('text-m-muted') + }) + + it('readonly : icône en text-black quand rempli', () => { + const wrapper = mountComponent({label: 'Tel', readonly: true, modelValue: '+33612345678'}) + expect(wrapper.get('[data-test="icon"]').classes()).toContain('text-black') + }) + + it('readonly : pas d\'apparence désactivée (pas opacity-40)', () => { + const wrapper = mountComponent({label: 'Tel', readonly: true}) + expect(wrapper.get('input').classes()).not.toContain('opacity-40') + // and the input is not natively disabled in readonly: + expect(wrapper.get('input').attributes('disabled')).toBeUndefined() }) it('renders the default add icon (mdi:plus)', () => { diff --git a/app/components/malio/input/InputPhone.vue b/app/components/malio/input/InputPhone.vue index b29c9ba..3f68fec 100644 --- a/app/components/malio/input/InputPhone.vue +++ b/app/components/malio/input/InputPhone.vue @@ -44,7 +44,7 @@