Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #547: Fixed Preview Navigator to act as normal browser on handling url history. #548

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions packages/app/src/app/components/Preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,15 @@ class BasePreview extends React.Component<Props, State> {
};

sendUrl = () => {
const { urlInAddressBar } = this.state;
const { urlInAddressBar, history, historyPosition } = this.state;
const position = historyPosition + 1;

// $FlowIssue
document.getElementById('sandbox').src = urlInAddressBar;

this.setState({
history: [urlInAddressBar],
historyPosition: 0,
history: [...history.slice(0, position), urlInAddressBar],
historyPosition: position,
urlInAddressBar,
});
};
Expand All @@ -286,8 +287,6 @@ class BasePreview extends React.Component<Props, State> {
document.getElementById('sandbox').src = url;

this.setState({
history: [url],
historyPosition: 0,
urlInAddressBar: url,
});
};
Expand All @@ -298,9 +297,15 @@ class BasePreview extends React.Component<Props, State> {
});

const { historyPosition, history } = this.state;
const position = historyPosition - 1;
const url = history[position];

// $FlowIssue
document.getElementById('sandbox').src = url;

this.setState({
historyPosition: this.state.historyPosition - 1,
urlInAddressBar: history[historyPosition - 1],
historyPosition: position,
urlInAddressBar: url,
});
};

Expand All @@ -310,9 +315,15 @@ class BasePreview extends React.Component<Props, State> {
});

const { historyPosition, history } = this.state;
const position = historyPosition + 1;
const url = history[position];

// $FlowIssue
document.getElementById('sandbox').src = url;

this.setState({
historyPosition: this.state.historyPosition + 1,
urlInAddressBar: history[historyPosition + 1],
historyPosition: position,
urlInAddressBar: url,
});
};

Expand Down