Skip to content

Commit

Permalink
docs: enable and document feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Jan 31, 2022
1 parent cee9f2e commit c8c11da
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addon/components/validated-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class ValidatedFormComponent extends Component {
await model.validate();

if (model.get("isInvalid")) {
if (this.config?.scrollErrorIntoView && model.errors[0]?.key) {
if (this.config?.features?.scrollErrorIntoView && model.errors[0]?.key) {
document
.querySelector(`[name=${model.errors[0].key}]`)
?.scrollIntoView();
Expand Down
10 changes: 10 additions & 0 deletions tests/dummy/app/snippets/config-features.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var ENV = {
// ...
"ember-validated-form": {
theme: "bootstrap",
features: {
scrollErrorIntoView: true,
}
},
// ...
};
7 changes: 7 additions & 0 deletions tests/dummy/app/templates/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ For instance:
{{demo.snippet 'permanent-custom-hint-component-template.hbs' label='permanent-custom-hint.hbs'}}
{{/docs-demo}}
<!-- prettier-ignore-end -->

## Other features

If you want to scroll the first invalid field into view, you can set the
`scrollErrorIntoView` property to `true` (default: false).

{{docs-snippet name='config-features.js' title='config/environment.js'}}
4 changes: 3 additions & 1 deletion tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ module.exports = function (environment) {
historySupportMiddleware: true,
"ember-validated-form": {
theme: "bootstrap",
scrollErrorIntoView: false,
defaults: {
hint: "permanent-custom-hint",
},
features: {
scrollErrorIntoView: false,
},
},
EmberENV: {
FEATURES: {
Expand Down

0 comments on commit c8c11da

Please sign in to comment.