Skip to content

Commit

Permalink
Resource Quota up-and-down input doesn't update the value on the requ…
Browse files Browse the repository at this point in the history
…est quota object to be sent

* add @change event to capture arrow presses on firefox

* address pr comments

---------

Co-authored-by: Alexandre Alves <aalves@Alexandres-MBP.lan>
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
(cherry picked from commit ac72cd8)
  • Loading branch information
aalves08 authored and mergify[bot] committed Jan 19, 2024
1 parent 241ca0b commit ccd3278
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ export default (
}
},
/**
* Emit on input change
*/
onChange(event: Event): void {
this.$emit('change', event);
},
/**
* Emit on input with delay. Note: Arrow function is avoided due context
* binding.
Expand Down Expand Up @@ -299,6 +306,7 @@ export default (
@input="onInput($event.target.value)"
@focus="onFocus"
@blur="onBlur"
@change="onChange"
>
</slot>

Expand Down
1 change: 1 addition & 0 deletions shell/components/form/UnitInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default {
:required="required"
:placeholder="placeholder"
:hide-arrows="hideArrows"
@change="update($event.target.value)"
@blur="update($event.target.value)"
>
<template #suffix>
Expand Down
4 changes: 2 additions & 2 deletions shell/components/form/__tests__/UnitInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ describe('component: UnitInput', () => {
expect(wrapper.isVisible()).toBe(true);
});

it('should emit input event on value change', async() => {
it.each(['blur', 'change'])('should emit input event when "%p" is fired', async(event) => {
const wrapper = mount(UnitInput, { propsData: { value: 1, delay: 0 } });
const input = wrapper.find('input');

await input.setValue(2);
await input.setValue(4);
input.trigger('blur');
input.trigger(event);

expect(wrapper.emitted('input')).toHaveLength(1);
});
Expand Down

0 comments on commit ccd3278

Please sign in to comment.