Skip to content

Commit 960f1da

Browse files
committed
feat(pos-add-relation): clear input after adding relation
1 parent f2ebc10 commit 960f1da

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

elements/src/components/pos-add-relation/pos-add-relation.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,10 @@ describe('pos-add-relation', () => {
103103
'http://xmlns.com/foaf/0.1/knows',
104104
'https://alice.test/profile/card#me',
105105
);
106+
await page.waitForChanges();
107+
108+
// and the value input is cleared
109+
expect(input.value).toEqual('');
110+
expect(page.rootInstance.currentValue).toBe('');
106111
});
107112
});

elements/src/components/pos-add-relation/pos-add-relation.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export class PosAddRelation {
2626
@State()
2727
selectedTermUri: string;
2828

29+
@State() currentValue: string;
30+
2931
private valueInput: HTMLInputElement;
3032

3133
async componentWillLoad() {
@@ -40,6 +42,7 @@ export class PosAddRelation {
4042

4143
async save(event) {
4244
await this.os.addRelation(this.resource, this.selectedTermUri, event.target.value);
45+
this.currentValue = '';
4346
}
4447

4548
render() {
@@ -52,6 +55,7 @@ export class PosAddRelation {
5255
<pos-select-term placeholder="Add relation" onPod-os:term-selected={ev => this.onTermSelected(ev)} />
5356
<input
5457
ref={el => (this.valueInput = el)}
58+
value={this.currentValue}
5559
type="url"
5660
aria-label="URI"
5761
placeholder=""

0 commit comments

Comments
 (0)