Skip to content

Commit

Permalink
STFORM-42 always permit navigation to /logout locations (#188)
Browse files Browse the repository at this point in the history
Always permit navigation to a `/logout` location, even if it would
normally be prevented due to a dirty form.

Refs STFORM-42
  • Loading branch information
zburke authored Aug 1, 2024
1 parent e18f523 commit 62950f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 9.1.0 IN PROGRESS

* Ignore the dirty-form prompt when navigating to a logout location. STFORM-42.

## [9.0.0](https://github.com/folio-org/stripes-form/tree/v9.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-form/compare/v8.0.0...v9.0.0)

Expand Down
7 changes: 7 additions & 0 deletions lib/StripesFormWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class StripesFormWrapper extends Component {
componentDidMount() {
if (this.props.formOptions.navigationCheck) {
this.unblock = this.props.history.block((nextLocation) => {
// STRIPESFF-35 / STFORM-42 require the nav-prompt to be ignored
// on logout. consider calling a common function if this ever needs
// to be more elaborate; until then, admire this simple WET impl.
if (nextLocation.pathname.startsWith('/logout')) {
return true;
}

const { dirty, submitSucceeded, submitting } = this.props;
const shouldPrompt = dirty && !submitSucceeded && !submitting;

Expand Down

0 comments on commit 62950f4

Please sign in to comment.