@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import React , { ChangeEvent , ContextType , createRef } from "react" ;
17
+ import React , { ChangeEvent , ContextType , createRef , SyntheticEvent } from "react" ;
18
18
import { MatrixEvent } from "matrix-js-sdk/src/models/event" ;
19
19
import { logger } from "matrix-js-sdk/src/logger" ;
20
20
@@ -32,13 +32,15 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
32
32
import SettingsFieldset from "../settings/SettingsFieldset" ;
33
33
34
34
interface IEditableAliasesListProps {
35
+ roomId ?: string ;
35
36
domain ?: string ;
36
37
}
37
38
38
39
class EditableAliasesList extends EditableItemList < IEditableAliasesListProps > {
39
40
private aliasField = createRef < RoomAliasField > ( ) ;
40
41
41
- private onAliasAdded = async ( ) => {
42
+ private onAliasAdded = async ( ev : SyntheticEvent ) => {
43
+ ev . preventDefault ( ) ;
42
44
await this . aliasField . current . validate ( { allowEmpty : false } ) ;
43
45
44
46
if ( this . aliasField . current . isValid ) {
@@ -51,7 +53,7 @@ class EditableAliasesList extends EditableItemList<IEditableAliasesListProps> {
51
53
} ;
52
54
53
55
protected renderNewItemField ( ) {
54
- const onChange = ( alias ) => this . onNewItemChanged ( { target : { value : alias } } ) ;
56
+ const onChange = ( alias : string ) => this . onNewItemChanged ( { target : { value : alias } } ) ;
55
57
return (
56
58
< form
57
59
onSubmit = { this . onAliasAdded }
@@ -63,7 +65,9 @@ class EditableAliasesList extends EditableItemList<IEditableAliasesListProps> {
63
65
ref = { this . aliasField }
64
66
onChange = { onChange }
65
67
value = { this . props . newItem || "" }
66
- domain = { this . props . domain } />
68
+ domain = { this . props . domain }
69
+ roomId = { this . props . roomId }
70
+ />
67
71
< AccessibleButton onClick = { this . onAliasAdded } kind = "primary" >
68
72
{ _t ( "Add" ) }
69
73
</ AccessibleButton >
@@ -360,7 +364,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
360
364
</ Field >
361
365
) ;
362
366
363
- let localAliasesList ;
367
+ let localAliasesList : JSX . Element ;
364
368
if ( this . state . localAliasesLoading ) {
365
369
localAliasesList = < Spinner /> ;
366
370
} else {
@@ -428,6 +432,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
428
432
itemsLabel = { _t ( 'Other published addresses:' ) }
429
433
noItemsLabel = { _t ( 'No other published addresses yet, add one below' ) }
430
434
placeholder = { _t ( 'New published address (e.g. #alias:server)' ) }
435
+ roomId = { this . props . roomId }
431
436
/>
432
437
</ SettingsFieldset >
433
438
< SettingsFieldset
0 commit comments