Skip to content

Commit

Permalink
Fix resource-array props not removed when input is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps committed Jun 25, 2024
1 parent 4bf258f commit 45b74ec
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This changelog covers all five packages, as they are (for now) updated as a whol
- [#896](https://github.com/atomicdata-dev/atomic-server/issues/896) Fix an issue where sidebar items require a double tap on iOS.
- Updated the look & feel of the sidebar a bit.
- [#893](https://github.com/atomicdata-dev/atomic-server/issues/893) Fix tables not showing any rows when viewing from a different server.
- Fix an issue where the resource-array properties would be set to an empty array instead of removing the property when removing all items in the input.

### @tomic/react

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function DriveSwitcher() {
disabled: !agent,
},
],
[savedDrivesMap, drive, historyMap],
[savedDrivesMap, drive, historyMap, agent],
);

return <DropdownMenu trigger={Trigger} items={items} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export default function InputResourceArray({
}

function handleClear() {
setArray([]);
setArray(undefined);
}

const handleRemoveRowList = useIndexDependantCallback(
(index: number) => () => {
const newArray = [...array];
newArray.splice(index, 1);
setArray(newArray);
setArray(newArray.length === 0 ? undefined : newArray);
},
array,
[setArray],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const options = Object.entries(reverseDatatypeMapping)
}))
.filter(x => x.value !== 'unknown-datatype');

const isResourceLike = (datatype: string) => {
return (
datatype === Datatype.ATOMIC_URL || datatype === Datatype.RESOURCEARRAY
);
};

export function PropertyDatatypePicker({
resource,
disabled,
Expand All @@ -30,12 +36,6 @@ export function PropertyDatatypePicker({
commit: true,
});

const isResourceLike = (datatype: string) => {
return (
datatype === Datatype.ATOMIC_URL || datatype === Datatype.RESOURCEARRAY
);
};

const clearInapplicableProps = (datatype: string) => {
if (!isResourceLike(datatype)) {
setClassType(undefined);
Expand Down
2 changes: 0 additions & 2 deletions browser/e2e/tests/filePicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const createModel = async (page: Page) => {

await expect(page.locator(`h1:has-text("${ONTOLOGY_NAME}")`)).toBeVisible();

page.getByRole('button', { name: 'Edit', exact: true }).click();

await page.getByRole('button', { name: 'Add class', exact: true }).click();
await page.getByPlaceholder('shortname').fill('robot');
await page.getByRole('button', { name: 'Save' }).click();
Expand Down
1 change: 0 additions & 1 deletion browser/e2e/tests/ontology.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ test.describe('Ontology', async () => {
await page.locator('dialog[open] button:has-text("Create")').click();
await expect(page.locator(`h1:has-text("${ontologyName}")`)).toBeVisible();

await page.getByRole('button', { name: 'Edit', exact: true }).click();
await page
.getByTestId('markdown-editor')
.fill('Data model for youtube thumbnail editor');
Expand Down

0 comments on commit 45b74ec

Please sign in to comment.