-
Notifications
You must be signed in to change notification settings - Fork 4.7k
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
backspace on chips trigger browser "back" #3923
Comments
@Thanood I was not able to reproduce on your codepen or the official website. Can you check again and confirm on the latest build? |
@developeranirudhprabhu It still happens on the official web page and in the CodePen (if there's a previous page of course). I've tested with Chrome, Edge and Firefox. Which browser are you using? |
@Thanood I'm testing on chrome 55. I followed the steps you have mentioned but could not reproduce the issue |
Interesting.. I had an older Chrome version and upgraded to 55. Doesn't happen anymore in Chrome 55. Would a |
I need to check why it happens. Ideally if the chips.length is 0 then nothing should happen |
Just to be precise, please note that this does not only happen when |
So you mean to say that irrespective of number of chips double backspace causes issues? |
Yes. In fact if you hit Thus my proposal to prevent the default action if |
I think some thing is going wrong here: https://github.com/Dogfalo/materialize/blob/master/js/chips.js#L84 |
Can you try removing
And see if it helps |
Update: Removing previously mentioned line solves the problem. Would create the PR for same tonight |
Interesting.. I'll try it, too when I have some time (I'm currently at work). |
Sure. Please try and let me know your feedback |
@Thanood did you try? Did it work for you? |
@developeranirudhprabhu Not quite.. Hard to describe somehow. With these lines not removed, the chip to be deleted is first selected (changes its background color to accent) then after another Now with these lines removed chips behave differently. The chip to be deleted is not selected and is removed without triggering So when you have these chips: Focus the chip editor and press If you nowpress Btw. if you blur the input before the second backspace and focus it again it works. But tbh. I think the behaviour of first selecting the chip is a bit nicer. 😃 I've tried to debug this behaviour. I think |
ok i will think of some alternate solution. I think we need to stop the event propagation in that case |
@Thanood After looking through the issue. I think opting "preventDefault()" technique works better. I added following line
on line above following
It doesnt seem to trigger history.back. I tested it only on firefox. Here i think what was needed is the check of back space at the very beginning. |
@Thanood Lemme know if it works for you. Also if you plan to create PR? |
@developeranirudhprabhu That seems to fix it! 😃 I can create a PR but I need some time to do that. I'll try tomorrow. Thanks! |
@Thanood I will do it today |
Great, thanks! 👍 |
Fixed in dbf25fa |
@Thanood Can you check the latest fix and confirm? |
Description
When trying to delete a chip with backspace (twice, the first highlights the chip, the second removes the chip), the chip is removed but when you visited another page before, the browser
back
history function is triggered and thus navigates to the previous page.(on Chrome 54)
Repro Steps
For example, open the Materialize homepage, then go to "Components => Chips", browse to the "Plugin" section there. Focus the chip input of the example and delete the last chip by hitting
backspace
twice.You should be on the homepage again. 😃
Screenshots / Codepen
See Materialize homepage or: http://codepen.io/anon/pen/wogVEY?editors=1010
(you would need to have a previous page when using the CodePen)
The text was updated successfully, but these errors were encountered: