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

Scroll to the error message by default #1023

Merged

Conversation

m-idler
Copy link
Contributor

@m-idler m-idler commented Jun 6, 2017

Messages might appear outside of users viewport. This PR fixes this by scrolling global messages into the users viewport. Hiding the users keyboard doesn't fix the problem because of the huge amount of different resolutions and display ratios.
see #959

@luisrudge
Copy link
Contributor

Can you make a gif comparing both results?

@m-idler
Copy link
Contributor Author

m-idler commented Jun 8, 2017

Current state - you won't recognise any errors that occur
state-current
changed state - lock dialog will scroll to the position of the error message
state-new

In the previous commit we added a parameter scrollGlobalMessagesIntoView to not brake/change current behaviour. By default scrollGlobalMessagesIntoView is disabled.

@@ -183,7 +186,8 @@ export const ui = {
popupOptions: lock => getUIAttribute(lock, 'popupOptions'),
primaryColor: lock => getUIAttribute(lock, 'primaryColor'),
authButtonsTheme: lock => getUIAttribute(lock, 'authButtonsTheme'),
rememberLastLogin: m => tget(m, 'rememberLastLogin', getUIAttribute(m, 'rememberLastLogin'))
rememberLastLogin: m => tget(m, 'rememberLastLogin', getUIAttribute(m, 'rememberLastLogin')),
scrollGlobalMessagesIntoView: lock => getUIAttribute(lock, 'scrollGlobalMessagesIntoView')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be tget(m, 'scrollGlobalMessagesIntoView', getUIAttribute(m, 'scrollGlobalMessagesIntoView')),?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference? actually, I am not really sure what tget,tgetUI, etc are doing. However, all properties above don't use tget, so I would assume the current way to retrieve the option is sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. you're right. I was just looking at the rememberLastLogin option, but it is a special case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -211,7 +215,8 @@ function extractAuthOptions(options) {
sso,
state,
nonce
} = options.auth || {};
} =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to break line here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this was changed by prettier

@luisrudge
Copy link
Contributor

That's amazing. Thanks for the PR 🎉

luisrudge
luisrudge previously approved these changes Jun 8, 2017
@luisrudge
Copy link
Contributor

Alright, we're good. I just requested some feedback from our ui/ux designer. I'll wait for him before merging this. Thaaaaaaanks for the PR 👍

@m-idler
Copy link
Contributor Author

m-idler commented Jun 12, 2017

Added two small commits to fix one of the new tests and add some documentation for the new parameter to the README

@luisrudge
Copy link
Contributor

Hey, can you rebase this? THanks!

@m-idler m-idler force-pushed the scroll-global-lock-message-into-view branch from e1469fa to 9dae1ec Compare June 13, 2017 06:40
@beneliflo
Copy link
Contributor

I just tested and what I saw is the scroll it varies depends of the height. This happen too with you?

lock_scroll

@luisrudge
Copy link
Contributor

I think you have to refresh after resizing the height, no?

@beneliflo
Copy link
Contributor

beneliflo commented Jun 13, 2017

@luisrudge with refresh. Same:

lock_scroll_2

@luisrudge
Copy link
Contributor

thanks @beneliflo. Can you take a look @m-idler?

@m-idler
Copy link
Contributor Author

m-idler commented Jun 14, 2017

I can reproduce the mentioned behaviour with small viewport heights too. After playing around with it a little bit, it seems that it's not caused by the scrolling itself but by the focus being set to the first input later.
In chrome.jsx I changed the timeout value from 17 to 1000 for testing:

if (!prevProps.error && error) {
      const input = this.findAutofocusInput();
      if (input) {
        // TODO clear timeout
        setTimeout(() => input.focus(), 1000);
      }
      return;
}

For chrome, it seems that the focused input is vertically-center-scrolled into the viewport, in firefox it's just scrolled at any position into the viewport. You can see the behaviour of Chrome and Firefox in the attached gifs.

Im not sure if it's a (good) solution, to skip setting the focus when scrollGlobalMessagesIntoView is enabled

chrome-focus
firefox-focus

@luisrudge
Copy link
Contributor

Thanks @m-idler. Just to give you a feedback, I'm discussing internally with our design team if we should keep the scroll-to-input behaviour at all. I'm also discussing if we should make scrollGlobalMessagesIntoView default to true instead of false. I'll push to your branch once I receive the final answer.

@luisrudge luisrudge force-pushed the scroll-global-lock-message-into-view branch from 9dae1ec to e3e7e15 Compare June 14, 2017 19:27
@luisrudge luisrudge force-pushed the scroll-global-lock-message-into-view branch from e3e7e15 to 22cc74d Compare June 14, 2017 19:32
@luisrudge
Copy link
Contributor

Thanks @m-idler for all your effort. I made a small change to make this the default behaviour and removing the scroll-to-input behaviour-on-error that you pointed out. Starting from the next release, scrollGlobalMessagesIntoView will be true by default. 🎉

@luisrudge luisrudge merged commit eef2aa3 into auth0:master Jun 14, 2017
@luisrudge
Copy link
Contributor

🎉 :shipit: 🚀

@luisrudge luisrudge changed the title Scroll messages in all lock dialogs into view Add scroll to the error message by default Jun 14, 2017
@luisrudge luisrudge changed the title Add scroll to the error message by default Scroll to the error message by default Jun 14, 2017
@m-idler m-idler deleted the scroll-global-lock-message-into-view branch June 19, 2017 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants