Allow "smart" quotes to enclose phrase when searching

Allow "smart" quotes to enclose phrase when searching

elnjensenelnjensen Posts: 12Questions: 4Answers: 0
edited June 18 in Feature requests

The option to search for an exact phrase in a table by enclosing it in double quotes is very useful. However, it doesn't work as intuitively as it might for mobile Safari users (e.g. iPhone, iPad) since those browsers insert smart (curly) quotes by default from the keyboard, and the DataTables search then uses that as part of the search string (i.e. it searches for that smart quote character in the table). It is possible for those users to make phrase search work by using a long press on the double-quote key to get a straight quote instead of a curly quote, but the number of users who figure that out is likely to be small.

Allowing smart quotes to enclose a search phrase would solve this, though presumably it would also remove the ability to search for those characters in the table (only a mild downside IMO, but I don't know the range of use cases people have).

Answers

  • kthorngrenkthorngren Posts: 19,496Questions: 26Answers: 4,619
    edited June 18

    I haven't enabled smart quotes so not sure exactly how they work. One option might be to create your own search input or hijack Datatables default search input, for example:
    https://live.datatables.net/kiwoxuma/83/edit

    In the event handler remove the characters you don't want as part of the search term.

    Kevin

  • elnjensenelnjensen Posts: 12Questions: 4Answers: 0
    edited June 18

    Thanks for the response!

    I haven't enabled smart quotes so not sure exactly how they work.

    The default setting since iOS 11 is for "Smart punctuation" to be turned on (in Settings -> General -> Keyboard), which means that pressing the double-quote keyboard key inserts either Unicode 201C or 201D (opening or closing curly double quotes, depending on context) rather than Unicode 0022 (straight double quote, ASCII decimal 34). Since the setting is quite buried and is the default, most iOS will likely have it turned on.

    One option might be to create your own search input or hijack Datatables default search input, for example:
    https://live.datatables.net/kiwoxuma/83/edit

    Sure, everyone could roll their own (and I appreciate the pointer to that solution) - but with mobile browsers dominating page views now (phone + tablet is ~60%), I thought it might be worth at least pointing this out and seeing if a more general solution would be worth discussing. It wouldn't need to be browser-specific or anything hacky like that - the search box could just accept any of U+201C, U+201D, or U+0022 as characters that would delimit an exact search phrase.

  • kthorngrenkthorngren Posts: 19,496Questions: 26Answers: 4,619

    Thanks for the explanation of Smart punctuation. I have not looked at this feature before.

    I figured you were asking for a feature to be added to Datatables to support this. I'm not speaking for @allan but this is the first time I've seen this question asked. I'm not sure where Allan would put this in a priority list but knowing he has a lot of projects going I presented an option that you might be able to use now.

    Lets wait to see what Allan says.

    Kevin

  • allanallan Posts: 60,325Questions: 1Answers: 9,798 Site admin

    I say that smart quotes are a real pain! They look superb in print, but I've yet to be convinced by their usefulness on screen. Back when I first got this site going the syntax highlighter converted quotes (single and double) into smart quotes - so any copy and paste of the code would result in a syntax error!

    Anyway, moan over - it's a relatively simple change to how the double quote detection works to allow for smart quotes to be supported as well (this page demonstrates the change to the algorithm), so I've committed that. It will be in the nightly shortly and in the next release.

    Allan

  • elnjensenelnjensen Posts: 12Questions: 4Answers: 0

    Thanks, Allan! This is one of those decidedly uninteresting issues, but hopefully your fix will make things "just work" for more users. I appreciate your quick help, as always.

Sign In or Register to comment.