{"action":"created","issue":{"url":"https://api.github.com/repos/material-components/material-components-web/issues/1398","repository_url":"https://api.github.com/repos/material-components/material-components-web","labels_url":"https://api.github.com/repos/material-components/material-components-web/issues/1398/labels{/name}","comments_url":"https://api.github.com/repos/material-components/material-components-web/issues/1398/comments","events_url":"https://api.github.com/repos/material-components/material-components-web/issues/1398/events","html_url":"https://github.com/material-components/material-components-web/issues/1398","id":263801062,"number":1398,"title":"Snackbar not closing","user":{"login":"pndewit","id":2362039,"avatar_url":"https://avatars1.githubusercontent.com/u/2362039?v=4","gravatar_id":"","url":"https://api.github.com/users/pndewit","html_url":"https://github.com/pndewit","followers_url":"https://api.github.com/users/pndewit/followers","following_url":"https://api.github.com/users/pndewit/following{/other_user}","gists_url":"https://api.github.com/users/pndewit/gists{/gist_id}","starred_url":"https://api.github.com/users/pndewit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pndewit/subscriptions","organizations_url":"https://api.github.com/users/pndewit/orgs","repos_url":"https://api.github.com/users/pndewit/repos","events_url":"https://api.github.com/users/pndewit/events{/privacy}","received_events_url":"https://api.github.com/users/pndewit/received_events","type":"User","site_admin":false},"labels":[{"id":494904464,"url":"https://api.github.com/repos/material-components/material-components-web/labels/bug","name":"bug","color":"ee0701","default":true},{"id":495093973,"url":"https://api.github.com/repos/material-components/material-components-web/labels/in-tracker","name":"in-tracker","color":"CE5C17","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-10-09T07:08:13Z","updated_at":"2018-02-04T19:59:37Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### What MDC-Web Version are you using?\r\n0.22.0\r\n\r\n### What browser(s) is this bug affecting?\r\nChrome (Version 61.0.3163.100 (Official Build) (64-bit))\r\nUser agent: \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\"\r\n\r\n### What OS are you using?\r\nmacOS Sierra (version 10.12.6)\r\n\r\n### What are the steps to reproduce the bug?\r\n1) Open Snackbar demo page: https://material-components-web.appspot.com/snackbar.html\r\n2) Snackbar settings should be left as is (only Dismiss on action enabled)\r\n3) Click the \"Show\" button twice and switch browser tab (within the 2750ms timer which should close the first snackbar and open the second one)\r\n4) Switch back to the snackbar demo tab and the snackbar never closes (even when setting focus on other elements)\r\n\r\n### What is the expected behavior?\r\nThe snackbar should close.\r\n\r\n### What is the actual behavior?\r\nIt doesn't close.\r\n\r\n### Any other information you believe would be useful?\r\nI was digging through the Snackbar component and found out that it gets focus when switching tab to the tab that is showing the snackbar. When it has focus, it doesn't close (expected behaviour). The blur handler should then kick in when moving focus to some other element, but AFAIK the blur handler doesn't trigger any more. I am not sure yet why. The blur handler does kick in when performing the steps above, but clicking the \"Show\" button only once at step 3.\r\n\r\nBesides the actual bug I'd also like to know why the Snackbar gets focus when switching tab? Shouldn't it just continue (or restart) the snackbar timer for closure?\r\n\r\n**EDIT**:\r\nFound a dirty workaround: manually set the snackbarHasFocus variable to false when the visibility change handler is triggered (make sure the MDC visibility change handler is run first by using setTimeout as it sets the snackbarHasFocus variable to true...) and there is a Snackbar queue."},"comment":{"url":"https://api.github.com/repos/material-components/material-components-web/issues/comments/362934713","html_url":"https://github.com/material-components/material-components-web/issues/1398#issuecomment-362934713","issue_url":"https://api.github.com/repos/material-components/material-components-web/issues/1398","id":362934713,"user":{"login":"piotr-cz","id":612953,"avatar_url":"https://avatars2.githubusercontent.com/u/612953?v=4","gravatar_id":"","url":"https://api.github.com/users/piotr-cz","html_url":"https://github.com/piotr-cz","followers_url":"https://api.github.com/users/piotr-cz/followers","following_url":"https://api.github.com/users/piotr-cz/following{/other_user}","gists_url":"https://api.github.com/users/piotr-cz/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-cz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-cz/subscriptions","organizations_url":"https://api.github.com/users/piotr-cz/orgs","repos_url":"https://api.github.com/users/piotr-cz/repos","events_url":"https://api.github.com/users/piotr-cz/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-cz/received_events","type":"User","site_admin":false},"created_at":"2018-02-04T19:59:37Z","updated_at":"2018-02-04T19:59:37Z","author_association":"NONE","body":"Update:\r\nSo the problem is that after login/ logout I'm closing modal window (previously focused element receives a focus element) and showing a snackbar.\r\n\r\nUnfortunately this also triggers snackbars' `hijackFocus` trick and that's why it desn't close and workaround with triggering snacbar with a timeout works.\r\n\r\nSnackbar should check if the focused element is a snackbar and only then use the `hijackFocus` thing"}}
{"actor":{"display_login":"piotr-cz"}}