@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React , { ChangeEvent , ContextType , createRef } from "react" ;
17+ import React , { ChangeEvent , ContextType , createRef , SyntheticEvent } from "react" ;
1818import { MatrixEvent } from "matrix-js-sdk/src/models/event" ;
1919import { logger } from "matrix-js-sdk/src/logger" ;
2020
@@ -32,13 +32,15 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
3232import SettingsFieldset from "../settings/SettingsFieldset" ;
3333
3434interface IEditableAliasesListProps {
35+ roomId ?: string ;
3536 domain ?: string ;
3637}
3738
3839class EditableAliasesList extends EditableItemList < IEditableAliasesListProps > {
3940 private aliasField = createRef < RoomAliasField > ( ) ;
4041
41- private onAliasAdded = async ( ) => {
42+ private onAliasAdded = async ( ev : SyntheticEvent ) => {
43+ ev . preventDefault ( ) ;
4244 await this . aliasField . current . validate ( { allowEmpty : false } ) ;
4345
4446 if ( this . aliasField . current . isValid ) {
@@ -51,7 +53,7 @@ class EditableAliasesList extends EditableItemList<IEditableAliasesListProps> {
5153 } ;
5254
5355 protected renderNewItemField ( ) {
54- const onChange = ( alias ) => this . onNewItemChanged ( { target : { value : alias } } ) ;
56+ const onChange = ( alias : string ) => this . onNewItemChanged ( { target : { value : alias } } ) ;
5557 return (
5658 < form
5759 onSubmit = { this . onAliasAdded }
@@ -63,7 +65,9 @@ class EditableAliasesList extends EditableItemList<IEditableAliasesListProps> {
6365 ref = { this . aliasField }
6466 onChange = { onChange }
6567 value = { this . props . newItem || "" }
66- domain = { this . props . domain } />
68+ domain = { this . props . domain }
69+ roomId = { this . props . roomId }
70+ />
6771 < AccessibleButton onClick = { this . onAliasAdded } kind = "primary" >
6872 { _t ( "Add" ) }
6973 </ AccessibleButton >
@@ -360,7 +364,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
360364 </ Field >
361365 ) ;
362366
363- let localAliasesList ;
367+ let localAliasesList : JSX . Element ;
364368 if ( this . state . localAliasesLoading ) {
365369 localAliasesList = < Spinner /> ;
366370 } else {
@@ -428,6 +432,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
428432 itemsLabel = { _t ( 'Other published addresses:' ) }
429433 noItemsLabel = { _t ( 'No other published addresses yet, add one below' ) }
430434 placeholder = { _t ( 'New published address (e.g. #alias:server)' ) }
435+ roomId = { this . props . roomId }
431436 />
432437 </ SettingsFieldset >
433438 < SettingsFieldset
0 commit comments