Skip to content

Time format render doesn't support seconds yet schema validation on time format expects it #2452

Closed
@kairos0ne

Description

@kairos0ne

Describe the bug

Image

Basically the renderer for Vue doesn't support seconds in time but the ISO standard and so does schema validation require it

Expected behavior

The render should allow seconds selection and if none selected default to ":00"

Activity

kairos0ne

kairos0ne commented on May 26, 2025

@kairos0ne
Author

I think the html render just needs the step attribute step="2"

sdirix

sdirix commented on May 26, 2025

@sdirix
Member

Thanks for the report. Can you contribute the fix?

added theissue type on May 26, 2025
kairos0ne

kairos0ne commented on May 26, 2025

@kairos0ne
Author

Yeah np, however I have a question.

Do you want to simply add the attribute step="2" or do you want to add dynamically with an option ?

kairos0ne

kairos0ne commented on May 26, 2025

@kairos0ne
Author

I tried to push a fix but I'm not listed contributer...

if you change the TimeControlRenderer.vue it requires a 1 line change
:step="appliedOptions.step > 0 ? appliedOptions.step : undefined"

That way you can support both.

<template>
  <control-wrapper
    v-bind="controlWrapper"
    :styles="styles"
    :is-focused="isFocused"
    :applied-options="appliedOptions"
  >
    <input
      :id="control.id + '-input'"
      type="time"
      :step="appliedOptions.step > 0 ? appliedOptions.step : undefined"
      :class="styles.control.input"
      :value="control.data"
      :disabled="!control.enabled"
      :autofocus="appliedOptions.focus"
      :placeholder="appliedOptions.placeholder"
      @change="onChange"
      @focus="isFocused = true"
      @blur="isFocused = false"
    />
  </control-wrapper>
</template>

<script lang="ts">
import {
  ControlElement,
  JsonFormsRendererRegistryEntry,
  rankWith,
  isTimeControl,
} from '@jsonforms/core';
import { defineComponent } from 'vue';
import {
  rendererProps,
  useJsonFormsControl,
  RendererProps,
} from '../../config/jsonforms';
import { default as ControlWrapper } from './ControlWrapper.vue';
import { useVanillaControl } from '../util';

const controlRenderer = defineComponent({
  name: 'TimeControlRenderer',
  components: {
    ControlWrapper,
  },
  props: {
    ...rendererProps<ControlElement>(),
  },
  setup(props: RendererProps<ControlElement>) {
    return useVanillaControl(
      useJsonFormsControl(props),
      (target) => target.value || undefined
    );
  },
});

export default controlRenderer;

export const entry: JsonFormsRendererRegistryEntry = {
  renderer: controlRenderer,
  tester: rankWith(2, isTimeControl),
};
</script>
kairos0ne

kairos0ne commented on May 27, 2025

@kairos0ne
Author

here is the pull #2453

I left with the logic that if not supplied it will set 'undefined' which will produce the behaviour you have today. This means it will not break existing implementations but technically the default behavour should be to set it as step="2" and set undefined as a fallback if option "step":"undefined" is set. This is just my opinion as the default time picker in my opinion should be to set a valid ISO time.

Best
Scott

linked a pull request that will close this issuefix: append seconds in Vue Vanilla time #2455on May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @sdirix@kairos0ne

      Issue actions

        Time format render doesn't support seconds yet schema validation on time format expects it · Issue #2452 · eclipsesource/jsonforms