diff --git a/projects/addon-mobile/styles/ios/search.less b/projects/addon-mobile/styles/ios/search.less index 4866dd27a63b..ccaf30ea39c7 100644 --- a/projects/addon-mobile/styles/ios/search.less +++ b/projects/addon-mobile/styles/ios/search.less @@ -16,7 +16,7 @@ input[type='search'][tuiSearch] { color: var(--tui-text-primary); caret-color: var(--tui-text-action); background: var(--tui-background-neutral-2) - url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M4%2010.4714C4%206.90319%206.93142%204%2010.5343%204C14.1372%204%2017.0686%206.90319%2017.0686%2010.4714C17.0686%2011.9473%2016.5691%2013.3016%2015.7257%2014.3882L19.7298%2018.3781C19.9017%2018.5484%2020%2018.7836%2020%2019.0431C20%2019.5864%2019.6151%2020%2019.0583%2020C18.7963%2020%2018.5507%2019.9108%2018.3623%2019.7243L14.3337%2015.7263C13.261%2016.4886%2011.9591%2016.9427%2010.5343%2016.9427C6.93142%2016.9427%204%2014.0395%204%2010.4714ZM5.4002%2010.4714C5.4002%2013.2772%207.70113%2015.556%2010.5343%2015.556C13.3675%2015.556%2015.6684%2013.2772%2015.6684%2010.4714C15.6684%207.66548%2013.3675%205.38672%2010.5343%205.38672C7.70113%205.38672%205.4002%207.66548%205.4002%2010.4714Z%22%20fill%3D%22%239299A2%22%2F%3E%3C%2Fsvg%3E) + url('data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M4%2010.4714C4%206.90319%206.93142%204%2010.5343%204C14.1372%204%2017.0686%206.90319%2017.0686%2010.4714C17.0686%2011.9473%2016.5691%2013.3016%2015.7257%2014.3882L19.7298%2018.3781C19.9017%2018.5484%2020%2018.7836%2020%2019.0431C20%2019.5864%2019.6151%2020%2019.0583%2020C18.7963%2020%2018.5507%2019.9108%2018.3623%2019.7243L14.3337%2015.7263C13.261%2016.4886%2011.9591%2016.9427%2010.5343%2016.9427C6.93142%2016.9427%204%2014.0395%204%2010.4714ZM5.4002%2010.4714C5.4002%2013.2772%207.70113%2015.556%2010.5343%2015.556C13.3675%2015.556%2015.6684%2013.2772%2015.6684%2010.4714C15.6684%207.66548%2013.3675%205.38672%2010.5343%205.38672C7.70113%205.38672%205.4002%207.66548%205.4002%2010.4714Z%22%20fill%3D%22%239299A2%22%2F%3E%3C%2Fsvg%3E') no-repeat 0.25rem center; &::placeholder { @@ -39,7 +39,7 @@ input[type='search'][tuiSearch] { margin: 0; background: var(--tui-text-secondary); opacity: 1; - mask: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M8%2016C3.63137%2016%200%2012.3686%200%208C0%203.62353%203.62353%200%207.99216%200C12.3686%200%2016%203.62353%2016%208C16%2012.3686%2012.3765%2016%208%2016ZM5.36471%2011.2941C5.5451%2011.2941%205.7098%2011.2314%205.83529%2011.1059L8%208.92549L10.1725%2011.1059C10.2902%2011.2314%2010.4549%2011.2941%2010.6353%2011.2941C11.0039%2011.2941%2011.2941%2011.0039%2011.2941%2010.6431C11.2941%2010.4627%2011.2314%2010.298%2011.098%2010.1804L8.92549%208.00784L11.1059%205.82745C11.2471%205.68627%2011.302%205.5451%2011.302%205.36471C11.302%205.00392%2011.0118%204.72157%2010.651%204.72157C10.4784%204.72157%2010.3373%204.77647%2010.2039%204.9098L8%207.09804L5.81176%204.91765C5.68627%204.8%205.5451%204.73726%205.36471%204.73726C5.00392%204.73726%204.72157%205.01177%204.72157%205.38039C4.72157%205.55294%204.78431%205.7098%204.9098%205.83529L7.08235%208.00784L4.9098%2010.1882C4.78431%2010.3059%204.72157%2010.4706%204.72157%2010.6431C4.72157%2011.0039%205.00392%2011.2941%205.36471%2011.2941Z%22%20fill%3D%22black%22%2F%3E%3C%2Fsvg%3E) + mask: url('data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M8%2016C3.63137%2016%200%2012.3686%200%208C0%203.62353%203.62353%200%207.99216%200C12.3686%200%2016%203.62353%2016%208C16%2012.3686%2012.3765%2016%208%2016ZM5.36471%2011.2941C5.5451%2011.2941%205.7098%2011.2314%205.83529%2011.1059L8%208.92549L10.1725%2011.1059C10.2902%2011.2314%2010.4549%2011.2941%2010.6353%2011.2941C11.0039%2011.2941%2011.2941%2011.0039%2011.2941%2010.6431C11.2941%2010.4627%2011.2314%2010.298%2011.098%2010.1804L8.92549%208.00784L11.1059%205.82745C11.2471%205.68627%2011.302%205.5451%2011.302%205.36471C11.302%205.00392%2011.0118%204.72157%2010.651%204.72157C10.4784%204.72157%2010.3373%204.77647%2010.2039%204.9098L8%207.09804L5.81176%204.91765C5.68627%204.8%205.5451%204.73726%205.36471%204.73726C5.00392%204.73726%204.72157%205.01177%204.72157%205.38039C4.72157%205.55294%204.78431%205.7098%204.9098%205.83529L7.08235%208.00784L4.9098%2010.1882C4.78431%2010.3059%204.72157%2010.4706%204.72157%2010.6431C4.72157%2011.0039%205.00392%2011.2941%205.36471%2011.2941Z%22%20fill%3D%22black%22%2F%3E%3C%2Fsvg%3E') no-repeat center; } diff --git a/projects/legacy/components/input-time/input-time.component.ts b/projects/legacy/components/input-time/input-time.component.ts index 5b1c9180f885..9c871541e6b6 100644 --- a/projects/legacy/components/input-time/input-time.component.ts +++ b/projects/legacy/components/input-time/input-time.component.ts @@ -281,13 +281,12 @@ export class TuiInputTimeComponent } private findNearestTimeFromItems(value: TuiTime): TuiTime | null { - return this.items.reduce( - (previous, current) => - Math.abs(current.valueOf() - value.valueOf()) < - Math.abs(previous.valueOf() - value.valueOf()) - ? current - : previous, - new TuiTime(0, 0), + // eslint-disable-next-line no-restricted-syntax + return this.items.reduce((previous, current) => + Math.abs(current.valueOf() - value.valueOf()) < + Math.abs(previous.valueOf() - value.valueOf()) + ? current + : previous, ); } diff --git a/projects/legacy/components/input-time/test/input-time.component.spec.ts b/projects/legacy/components/input-time/test/input-time.component.spec.ts index 990d02f424d6..4a11ae8c17d8 100644 --- a/projects/legacy/components/input-time/test/input-time.component.spec.ts +++ b/projects/legacy/components/input-time/test/input-time.component.spec.ts @@ -17,7 +17,6 @@ import { import {tuiCreateKeyboardEvent, TuiNativeInputPO, TuiPageObject} from '@taiga-ui/testing'; const TIMES = [ - new TuiTime(0, 0), new TuiTime(0, 30), new TuiTime(1, 0), new TuiTime(1, 30), @@ -284,7 +283,7 @@ describe('InputTime', () => { pageObject.getByAutomationId('tui-input-time__item')!.nativeElement.click(); expect(testComponent.control.value?.toString().trim()).toBe( - TIMES[6]?.toString(), + TIMES[5]?.toString(), ); }); @@ -321,6 +320,15 @@ describe('InputTime', () => { expect(testComponent.control.value?.toString().trim()).toBe('01:30'); }); + + it('with strict = true, the entered value is rounded to the nearest in items (00:00)', () => { + testComponent.strict = true; + fixture.detectChanges(); + inputPO.sendText('00:00'); + fixture.detectChanges(); + + expect(testComponent.control.value?.toString().trim()).toBe('00:30'); + }); }); });