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

Disable tab #110

Closed
adhsu opened this issue May 20, 2014 · 19 comments
Closed

Disable tab #110

adhsu opened this issue May 20, 2014 · 19 comments

Comments

@adhsu
Copy link

adhsu commented May 20, 2014

I didn't see this anywhere in the documentation, sorry if I missed it. I'd like to be able to disable tabbing, so that I can type a message and tab to a submit button/etc.

@ncammarata
Copy link

Related: how is tabindex set?

@jhchen
Copy link
Member

jhchen commented May 20, 2014

The somewhat hacky way to disable tabs right now is

var keyboard = editor.getModule('keyboard');
delete keyboard.hotkeys[9];    // 9 is the key code for tab

@ncammarata I didn't set the tabindex on any of our examples but it can be set to whatever is desired in the toolbar.

@kmoe
Copy link
Contributor

kmoe commented Aug 5, 2015

Would you appreciate a PR to add this as an option in the config? So you could do

var editor = new Quill('#editor', {
  tab: 'disabled'
});

or similar.

@kmoe
Copy link
Contributor

kmoe commented Aug 6, 2015

Actually it would be a module option rather than a top-level one. But you get the idea. Preparing PR now in case you do want this.

@jhchen
Copy link
Member

jhchen commented Aug 6, 2015

In this case I think a module might be too heavyweight. The best approach might just be to add an easy to use removeHotkey function to the keyboard module. Do you want to give this route a try?

@kmoe
Copy link
Contributor

kmoe commented Aug 6, 2015

Yes, sorry, by 'module option' I meant an option you can pass into a module rather than a new module! removeHotkey makes sense and would be easy to do.
Do you think it should just take the raw key number (removeHotkey(9)) or a string mapped using the dom module (removeHotkey('TAB'))?

@jhchen
Copy link
Member

jhchen commented Aug 6, 2015

Yes I think it should either take a hotkey object or string. If it's a string it should look up Keyboard.hotkeys and use that hotkey object.

@LeZuse
Copy link

LeZuse commented Sep 9, 2015

Just noticed that removeHotkey nicely solves the problem for the TAB keystroke, but does not work for Shift+TAB which is a bummer, because you obviously will not removeHotkey Shift. Any workaround suggestions?

@jhchen
Copy link
Member

jhchen commented Sep 10, 2015

You can pass in removeHotkeys({ key: dom.KEYS.TAB, shiftKey: true })

jhchen pushed a commit that referenced this issue Nov 10, 2015
Takes a string, number, or hotkey object.
@acidjazz
Copy link

acidjazz commented Sep 29, 2016

Why isn't this functionality documented anywhere after a year? I tried to find removeHotKeys or removeHotKey in the keyboard module and was unable to call it, I ended up finding I could

var keyboard = editor.getModule('keyboard');
delete keyboard.bindings[9];

I honestly think tab: 'disabled' or tabs: false is a more understandable and guessable option, especially with the mess for shift+tab as well

Also what about turning this on and off on the fly?

@benbro
Copy link
Contributor

benbro commented Sep 29, 2016

The keyboard module is documented here
You can use quill.keyboard.addBinding() to add a binding.

You can override the default bindings in the config:
http://codepen.io/anon/pen/JRJgQB

@acidjazz
Copy link

acidjazz commented Sep 29, 2016

@benbro thank you, I thought I had read through everything, but googling this instead brought me to this issue, maybe we can add examples of removeHotKey or removeHotKeys? Or were they removed and this is a more proper example now?

Your example also has a 'remove tab' do nothing which is more than the example documented; is this to fix shift+tab as well?

I still honestly think 19 lines of code is a bit much to disable tabs, still would recommend something close to what @kmoe originally suggested.

Glad to see this issue now ends w/ a link to the proper usage for now though.

@hhubik
Copy link

hhubik commented Oct 14, 2016

I have the opposite problem. I have an app with a few input elements, one of which is quill. I specified the tab order using the tabindex on each input element. That works fine, except when I tab to the quill element, the focus seems to be on the border of the element. How do I force the focus be in the text input area of quill so that when I start typing, the text goes in the right place? Thanks.

@benbro
Copy link
Contributor

benbro commented Oct 14, 2016

@hhubik can you please fork the codepen example, modify it to reproduce your case and open a new github issue describing it?

@hhubik
Copy link

hhubik commented Oct 15, 2016

@benbro I cannot re-create the problem in codepen. When I set the tabindex of the editor-container div, everything works as I expect (when I tab to the editor, the text input area gets the focus).

The issue I am having could be related to the fact that I am using quill hosted in the Angular2 component Editor from PrimeFaces.

When I set the tabindex on the Editor component, that is when I see the problem I described earlier. If anyone familiar with Angular 2 knows how I can set the tabindex on the editor-container inside of the Editor component, please let me know.

@aguynamedben
Copy link

I'm having the same problem @hhubik observed and re-created it in Codepen: http://codepen.io/aguynamedben/pen/KNBNBP

Is tabbing into a Quill instance from a previous form input supposed to work?

@edeych
Copy link

edeych commented Jul 6, 2017

@aguynamedben @hhubik

I worked around this by adding the following JQuery code after instantiating quill:

var inputTabIndex = $('#first-input').prop('tabindex');
$('.ql-editor').prop('tabindex', parseInt(inputTabIndex) + 1);

The idea is to get the previous input from which you are tabbing from and get its tabindex. Then get the class for the actual editor object which is .ql-editor, and set its tabindex to +1 of the previous input's tabindex.

@p10shinde
Copy link

Try this...

delete quill.getModule('keyboard').bindings["9"]

@maxant
Copy link

maxant commented May 18, 2024

delete quill.getModule('keyboard').bindings["9"]

in Quill 2.0, use "Tab" instead of "9":

delete quill.getModule('keyboard').bindings['Tab']

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

No branches or pull requests