Feature to prevent blur on button click

Feature to prevent blur on button click

tharglettharglet Posts: 7Questions: 2Answers: 0
edited August 2018 in Free community support

I wanted to add an on-blur event to a button, only to find that DataTables buttons forces a blur to happen, causing the action to happen prematurely. Not entirely sure why a blur would be forced on an action, especially when DataTables has NO idea what the user-defined action is going to be? In my case, I'm showing an extended menu, that wants to hide on blur.

The line of code is line 561 of DataTables buttons 1.5.3: button.blur();

Would it be possible for datatables buttons to have some configuration option to skip this blur?

(I'd also be happy with the line disappearing entirely, but if people are relying on this, I'm thinking it'd have to be added as a config option to disable)

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    It's done here. It blurs on click, otherwise the button retains focus and looks a little odd for someone using a mouse for navigation. For someone using a keyboard for navigation it will retain the focus and styled accordingly.

    Allan

  • tharglettharglet Posts: 7Questions: 2Answers: 0

    For us, this isn't entirely desirable - we'd prefer for buttons in our app to consistently not blur on interaction.

    If I prepared a PR which involves some form of option to turn this behaviour off for mouse clicking too, would there be a desire to merge it? (otherwise it'll be quicker for me to fork buttons and remove the undesired line).

    In speaking to the web designer for the project, he feels that both the clicking and keyboard interaction should be consistent, for accessibility as well as consistency.

    In his words:
    Accessibility: We need to ensure that html elements can behave as expected (make user of browser’s assistive features, honour user config and expectations etc)

    Consistency & usability: There’s an (unexplained to the user) difference between how things behave for clickers and keyboarders. Considering the users who switch between these methods, being able to normalise behaviour would help make it more intuitive experience.

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    Yes, I'd take a pull request for this - perhaps a clickBlurs option as a boolean that can be passed to each button.

    Allan

This discussion has been closed.