Skip to content

Commit 15eb4e4

Browse files
v1.1.1 (#7)
1 parent f405004 commit 15eb4e4

File tree

18 files changed

+85
-61
lines changed

18 files changed

+85
-61
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ The format is based on [Keep a Changelog][kac], and this project adheres to
2323
- Fetch button disabled while fetching
2424
- Location field aligns with current representation
2525

26+
## 1.1.1
27+
28+
### Fixed
29+
30+
- [#2]: Modals now close properly after navigation
31+
- Typo in sub-entities panel
32+
33+
[#2]: https://github.com/siren-js/api-browser/issues/2
34+
2635
## 1.1.0 - 2021-06-16
2736

2837
### Added

src/components/Location.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { withPreventDefault } from '../with';
23

34
export interface LocationProps {
45
onNavigate: (url: string) => void;
@@ -20,8 +21,7 @@ export default class Location extends React.Component<
2021
this.updateUrl = this.updateUrl.bind(this);
2122
}
2223

23-
submit(event: React.FormEvent<HTMLFormElement>) {
24-
event.preventDefault();
24+
submit() {
2525
this.props.onNavigate(this.state.url);
2626
}
2727

@@ -31,7 +31,7 @@ export default class Location extends React.Component<
3131

3232
render() {
3333
return (
34-
<form onSubmit={this.submit}>
34+
<form onSubmit={withPreventDefault(this.submit)}>
3535
<div className="columns is-mobile is-vcentered">
3636
<div className="column is-2 has-text-right">
3737
<label className="label" htmlFor="location">

src/components/navbar/NavbarBrand.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { withPreventDefault } from '../../with';
2+
13
export interface NavbarBrandProps {
24
targetElementId: string;
35
active: boolean;
@@ -10,10 +12,7 @@ export default function NavbarBrand(props: NavbarBrandProps) {
1012
<a
1113
className={`navbar-burger${props.active ? ' is-active' : ''}`}
1214
href="/#"
13-
onClick={(event) => {
14-
event.preventDefault();
15-
props.onBurgerClick();
16-
}}
15+
onClick={withPreventDefault(props.onBurgerClick)}
1716
role="button"
1817
aria-label="menu"
1918
aria-expanded={props.active}

src/components/navbar/SettingsItem.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Icon, IconSize, IconStyle } from '../util';
33
import { SettingsModal } from '../settings';
4+
import { withPreventDefault } from '../../with';
45

56
export interface SettingsItemState {
67
isModalActive: boolean;
@@ -34,10 +35,7 @@ export default class SettingsItem extends React.Component<
3435
<a
3536
href="/#"
3637
className="navbar-item"
37-
onClick={(event) => {
38-
event.preventDefault();
39-
this.activateModal();
40-
}}
38+
onClick={withPreventDefault(this.activateModal)}
4139
>
4240
<Icon name="cog" style={IconStyle.Solid} size={IconSize.Large} />
4341
</a>

src/components/render/Rendering.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {
55
RenderProps
66
} from '../../types';
77
import { Tags } from '../util';
8-
import ActionsPanel from './action';
9-
import LinksPanel from './link';
8+
import { ActionsPanel } from './action';
9+
import { LinksPanel } from './link';
1010
import Properties from './Properties';
11-
import SubEntitiesPanel from './sub-entity';
11+
import { SubEntitiesPanel } from './sub-entity';
1212

1313
export default function Rendering(props: RenderingProps) {
1414
const { cols } = props;

src/components/render/Tabs.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { withPreventDefault } from '../../with';
2+
13
export enum View {
24
Rendering,
35
Source
@@ -33,13 +35,7 @@ interface TabProps {
3335

3436
const Tab = (props: TabProps) => (
3537
<li className={props.isActive ? 'is-active' : ''}>
36-
<a
37-
href="/#"
38-
onClick={(e) => {
39-
e.preventDefault();
40-
props.onClick(props.view);
41-
}}
42-
>
38+
<a href="/#" onClick={withPreventDefault(() => props.onClick(props.view))}>
4339
{View[props.view]}
4440
</a>
4541
</li>

src/components/render/action/ActionForm.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { Field } from '@siren-js/core';
2-
import React from 'react';
2+
import { withPreventDefault } from '../../../with';
33
import InputControl from '../field';
44

5-
const withPreventDefault =
6-
(fn: () => void) => (event: React.BaseSyntheticEvent) => {
7-
event.preventDefault();
8-
fn();
9-
};
10-
115
export default function ActionForm({
126
fields,
137
onSubmit,

src/components/render/action/ActionsPanel.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import React from 'react';
21
import { Action } from '@siren-js/core';
2+
import React from 'react';
3+
import withFn, { withPreventDefault } from '../../../with';
4+
import { Panel } from '../../util';
35
import ActionFormModal from './ActionFormModal';
46

57
export default class ActionsPanel extends React.Component<
@@ -26,20 +28,19 @@ export default class ActionsPanel extends React.Component<
2628

2729
render() {
2830
return (
29-
<article className="panel is-info">
30-
<p className="panel-heading">Actions</p>
31+
<Panel title="Actions">
3132
{this.props.actions.map((action, index) => (
3233
<React.Fragment key={index}>
3334
<ActionPanelBlock action={action} onClick={this.activate} />
3435
<ActionFormModal
3536
active={this.state.activeModal === action.name}
3637
action={action}
3738
onClose={this.deactivate}
38-
onSubmit={this.props.onSubmit}
39+
onSubmit={withFn(this.props.onSubmit, this.deactivate)}
3940
/>
4041
</React.Fragment>
4142
))}
42-
</article>
43+
</Panel>
4344
);
4445
}
4546
}
@@ -57,10 +58,7 @@ const ActionPanelBlock = ({ action, onClick }: ActionPanelBlockProps) => (
5758
<a
5859
href="/#"
5960
className="panel-block"
60-
onClick={(e) => {
61-
e.preventDefault();
62-
onClick(action.name);
63-
}}
61+
onClick={withPreventDefault(() => onClick(action.name))}
6462
>
6563
<span className="panel-icon">
6664
<i className="fas fa-file-alt" aria-hidden="true"></i>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default } from './ActionsPanel';
1+
export { default as ActionsPanel } from './ActionsPanel';

src/components/render/link/LinkPanelBlock.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { Link } from '@siren-js/core';
2+
import { withPreventDefault } from '../../../with';
23

34
export default function LinkPanelBlock({ link, onClick }: LinkProps) {
45
const isActive = link.rel.includes('self');
56
return (
67
<a
78
href="/#"
89
className={`panel-block${isActive ? ' is-active' : ''}`}
9-
onClick={(e) => {
10-
e.preventDefault();
11-
onClick(link);
12-
}}
10+
onClick={withPreventDefault(() => onClick(link))}
1311
>
1412
<span className="panel-icon">
1513
<i className="fas fa-link" aria-hidden="true"></i>

0 commit comments

Comments
 (0)