Skip to content

Commit 4f264a7

Browse files
committed
feat(pos-add-relation): update current value on input
1 parent 960f1da commit 4f264a7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ describe('pos-add-relation', () => {
9595

9696
// when the user enters a URI
9797
const input = page.root.querySelector('input');
98+
fireEvent.input(input, { target: { value: 'https://alice.test/profile/card#me' } });
9899
fireEvent.change(input, { target: { value: 'https://alice.test/profile/card#me' } });
99100

100101
// then the relation is added

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export class PosAddRelation {
4040
this.selectedTermUri = event.detail.uri;
4141
}
4242

43-
async save(event) {
44-
await this.os.addRelation(this.resource, this.selectedTermUri, event.target.value);
43+
async save() {
44+
await this.os.addRelation(this.resource, this.selectedTermUri, this.currentValue);
4545
this.currentValue = '';
4646
}
4747

@@ -56,10 +56,11 @@ export class PosAddRelation {
5656
<input
5757
ref={el => (this.valueInput = el)}
5858
value={this.currentValue}
59+
onInput={ev => (this.currentValue = (ev.target as HTMLInputElement).value)}
5960
type="url"
6061
aria-label="URI"
6162
placeholder=""
62-
onChange={ev => this.save(ev)}
63+
onChange={() => this.save()}
6364
></input>
6465
</Host>
6566
);

0 commit comments

Comments
 (0)