For the purpose of custom autocompletion in a datepicker's input field, I want to disable the automatic formatting done when you tab out of a normal angular datepicker. I've seen this question, but a hidden input is not an option for me for technical/architectural reasons.
Either way, I've nailed down where the problem occurs, but that unfortunately doesn't mean that I've found a way to fully fix it (only ugly hacks that I don't really want to consider).
In the MatDatepickerInputBase class, the _onInput method calls the parse and format methods of the respective DateAdapter.
This means that I can either:
- override the
parseandformatmethods in my own DateAdapter or - attempt to somehow prevent these methods from being called
Ideally, I'd like to do the second option, but as that would probably require doing undesirable shenanigens with the MatDatepickerInputBase class, I assume it's not going to happen (I don't even know how I would override the _onInput method, if at all possible, and even if I could, it would be an atrocious hack that breaks every time Angular modifies the DatePicker).
This leaves overriding the methods in the DateAdapter.
However, the use case that I need this for is custom auto completion, which means that after the user types something, a highlighted autocompletion string is appended. Unfortunately, this autocompleted appendage isn't passed to the parse method, which receives the value before my key listeners (which are part of a directive on the datepicker) can modify it.
I'd prefer to not deal with the parse method at all, but since the format method doesn't have access to the originally passed input value, I can only deal with the passed date here, which should at least be the locale-specific interpretation of the complete input value (The NativeDateAdapter only uses en-US, while I need de-DE).
Is there some way for me to cause my key listeners to take precedence over the _onInput method? If not, is there any other way to solve my problem for which I lack the knowledge to come up with?