URLs can be dropped onto download textarea.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-05-02 13:35:08 -06:00
parent 7bf1c80847
commit ae460af8d6
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 37 additions and 2 deletions

View file

@ -424,7 +424,7 @@ export function UrlsTextarea({name = 'urls', required, form}) {
let urls = (inputProps.value || '').split('\n');
urls = [...urls, droppedUrl];
urls = urls.filter(i => !!i).join('\n');
inputAttrs.setValue(`${urls}\n`);
inputAttrs.localSetValue(`${urls}\n`);
};
const handleKeyDown = (event) => {

View file

@ -1,5 +1,5 @@
import React from 'react';
import {act, renderHook, screen, waitFor} from '@testing-library/react';
import {act, fireEvent, renderHook, screen, waitFor} from '@testing-library/react';
import {
commaSeparatedValidator,
InputForm,
@ -1001,5 +1001,40 @@ describe('Form Components', () => {
expect.objectContaining({name: 'urls'})
);
});
it('appends dropped URL via localSetValue on drop', () => {
// Regression: handleDrop previously called inputAttrs.setValue, which does
// not exist on the attrs returned by getInputProps. The correct helper is
// localSetValue.
const localSetValue = jest.fn();
const form = {
disabled: false,
formData: {urls: 'https://existing.example/'},
getInputProps: jest.fn(() => [
{
type: 'text',
disabled: false,
value: 'https://existing.example/',
name: 'urls',
onChange: jest.fn(),
error: null,
'data-path': 'urls',
},
{valid: true, path: 'urls', localSetValue},
]),
onSubmit: jest.fn(),
};
renderWithProviders(<UrlsTextarea form={form}/>);
const textarea = screen.getByPlaceholderText('Enter one URL per line');
fireEvent.drop(textarea, {
dataTransfer: {getData: () => 'https://dropped.example/'},
});
expect(localSetValue).toHaveBeenCalledWith(
'https://existing.example/\nhttps://dropped.example/\n'
);
});
});
});