From 2ff8ffef3c1b42f47be4c019e730f1f27f76c180 Mon Sep 17 00:00:00 2001 From: zernonia <59365435+zernonia@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:18:19 +0800 Subject: [PATCH] fix(PinInput): placeholder not showing after reseting the value programatically (#1530) * fix(PinInput): placeholder not showing after reseting the value programatically * test: include test Co-authored-by: antfu --- .../radix-vue/src/PinInput/PinInput.test.ts | 24 ++++++++++++++++++ .../radix-vue/src/PinInput/PinInputInput.vue | 25 +++++++++++++------ .../src/PinInput/story/_PinInput.vue | 5 ++++ 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/packages/radix-vue/src/PinInput/PinInput.test.ts b/packages/radix-vue/src/PinInput/PinInput.test.ts index 9e5ff6b7a..76ab91204 100644 --- a/packages/radix-vue/src/PinInput/PinInput.test.ts +++ b/packages/radix-vue/src/PinInput/PinInput.test.ts @@ -22,6 +22,14 @@ describe('given default PinInput', () => { expect(await axe(wrapper.element)).toHaveNoViolations() }) + it('should display input placeholders', () => { + expect(inputs[0].element.placeholder).toBe('') // first input was focused thus not showing placeholder + expect(inputs[1].element.placeholder).toBe('*') + expect(inputs[2].element.placeholder).toBe('*') + expect(inputs[3].element.placeholder).toBe('*') + expect(inputs[4].element.placeholder).toBe('*') + }) + describe('after user input', () => { beforeEach(async () => { await userEvent.keyboard('test') @@ -143,6 +151,22 @@ describe('given default PinInput', () => { it('should emit \'complete\' with the result', () => { expect(wrapper.emitted('complete')?.[0]?.[0]).toStrictEqual(['a', 'p', 'p', 'l', 'e']) }) + + describe('after resetting value', async () => { + beforeEach(async () => { + await userEvent.keyboard('apple') + const button = wrapper.find('button') + await button.trigger('click') + }) + + it('should display input placeholders', () => { + expect(inputs[0].element.placeholder).toBe('*') + expect(inputs[1].element.placeholder).toBe('*') + expect(inputs[2].element.placeholder).toBe('*') + expect(inputs[3].element.placeholder).toBe('*') + expect(inputs[4].element.placeholder).toBe('*') + }) + }) }) }) diff --git a/packages/radix-vue/src/PinInput/PinInputInput.vue b/packages/radix-vue/src/PinInput/PinInputInput.vue index 3aff8bdb9..3e3423c8b 100644 --- a/packages/radix-vue/src/PinInput/PinInputInput.vue +++ b/packages/radix-vue/src/PinInput/PinInputInput.vue @@ -12,7 +12,7 @@ export interface PinInputInputProps extends PrimitiveProps {